本帖最后由 u012293393 于 2014-09-04 16:22:57 编辑

解决方案 »

  1.   

    首先我很怀疑你原本的语句可以不报错???
    你要的应该是:select szzqmc 行政区名称,
           count(case when szjg='110000' then xzqdm else null end)  a,
           count(case when szjg='110000' and  zt=1 then xzqdm else null end)  下发数,
           count(case when szjg='110000' and  zt=1 and sftb='是' then xzqdm else null end) 应报矿山数,
           count(case when szjg='110000' and  sfytb=1 and sftb='是' then xzqdm else null end) 已报矿山数,
           count(case when szjg='110000'  and  zt=4 then xzqdm else null end)  已通过审查,
           count(case when exists(select 1 from scgc s where s.guid = b.guid and  b.szjg='0'and s.kfbszt = 1 and s.clbszt = 1)                  
               then xzqdm else null ) 已报上级
    from ksds  b
    group by szzqmc或者select szzqmc 行政区名称,
           count(xzqdm )  a,
           count(case when zt=1 then xzqdm else null end)  下发数,
           count(case when zt=1 and sftb='是' then xzqdm else null end) 应报矿山数,
           count(case when sfytb=1 and sftb='是' then xzqdm else null end) 已报矿山数,
           count(case when zt=4 then xzqdm else null end)  已通过审查,
           count(case when exists(select 1 from scgc s where s.guid = b.guid and  b.szjg='0'and s.kfbszt = 1 and s.clbszt = 1)                  
               then xzqdm else null ) 已报上级
    from ksds  b
    where szjg='110000'
    group by szzqmc注意上面两个是不相等的.