select a.hdpc,a.zcs,count(b.hdbz) as zcyhds from
(select zchdpc as hdpc,count(zcbh) as zcs from zchdjd group by zchdpc) a
left join zchdjd b
on b.zchdpc =a.hdpc and b.hdbz <> '' group by a.hdpc,a.zcs
select table1.a,table1.b,table2.c from
(selec a ,count(b) from table group by a ) as table1
(selec a, count(c) from table group by a where not c is null) as table2
where table1.a = table2.a
select table1.a,table1.b,table2.c from
(selec a ,count(b) from table group by a ) as table1
(selec a, count(c) from table group by a where not c is null) as table2
where table1.a = table2.a