17,086
社区成员
发帖
与我相关
我的任务
分享
select xm,bm,
(select count(1) from cfxx where t.rid=ryid),
(select count(1) from jlxx where t.rid=ryid),
(select count(1) from zdjlxx where t.rid=ryid)
from jbxx t
where exists(select 1 from cfxx where t.rid=ryid)
or exists(select 1 from jlxx where t.rid=ryid)
or exists(select 1 from zdjlxx where t.rid=ryid)
select am,bm,
(select count(1) from cfxx where t.rid=ryid),
(select count(1) from jlxx where t.rid=ryid),
(select count(1) from zdjlxx where t.rid=ryid)
from jbxx t
select xm,bm,
sum(case when t.flag = 1 then 1 end),
sum(case when t.flag = 2 then 1 end),
sum(case when t.flag = 3 then 1 end)
from jbxx t0,
( select ryid, 1 flag from cfxx
union all
select ryid, 2 flag from jlxx
union all
select ryid, 3 flag from zdjlxx
) t
where t0.rid = t.rid
group by t0.xm,t0.bm;