27,581
社区成员




SELECT *
FROM mt_house_relationPer_tbl_zq20130308
ORDER BY hou_client asc
select a.id
from mt_house_relationPer_tbl_zq20130308 a
where
exists( select id from get_Perinfo_fordept_fun('67,91',3 ) as getPer where del=1
AND hou_client= getPer.id )
order by a.id desc
select a.id
from mt_house_relationPer_tbl a
where
exists( select id from get_Perinfo_fordept_fun('67,91',3 ) as getPer where del=1
AND add_per= getPer.id )
order by a.id desc
exec test --这里有插入临时表
select * from #TMP --这样是会报错的
select a.idfrom mt_house_relationPer_tbl_zq20130308 a
inner join ( select id from get_Perinfo_fordept_fun('67,91',3 ) where del=1) b
on a.hou_client= getPer.id
order by a.id desc
有表值函数的关系, 试下这个。如果速度不行 还是建议用临时表。
--根据部门(区域)ID串,得到包括本身部门(区域)及所有子集部门(区域)下的所有人(包含离职
;with wsp as
(
select id,dept_name from agent_config.dbo.Agent_Department_Tbl where CHARINDEX(','+CAST(id AS VARCHAR(100))+',',','+@dept_id+',')>0 and isnull(del,0)=0
union all
select a.id,a.dept_name from agent_config.dbo.Agent_Department_Tbl a,wsp b where a.parent_id=b.id and isnull(a.del,0)=0
)
insert into @t
select per.id,per_name,ISNULL(per.del,1) del
from wsp a
inner join agent_config.dbo.mt_shop_tbl shop on a.id=shop.dept_id --这里把只查询未删除店的条件去掉了,因为数据查看下成交房源需要查看到所有人的,包含已删除的店
inner join agent_config.dbo.mt_per_tbl per on per.per_shop=shop.shopid
UNION
SELECT per.id,per_name,ISNULL(per.del,1) del
FROM wsp a
INNER JOIN agent_config.dbo.mt_per_tbl per on a.id=per.DEPT_ID
select id from get_Perinfo_fordept_fun('67,91',3 ) as getPer where del=1