汇总年度工资收入表
Select DwCode,Count(*) as rs,Sum(count_gz1) As count_gz1,Sum(count_gz2) As count_gz2,Sum(count_gz3) As count_gz3,Sum(count_gz4) As count_gz4,Sum(count_gz5) As count_gz5,Sum(count_gz6) As count_gz6,Sum(count_gz7) As count_gz7,Sum(count_gz8) As count_gz8,Sum(count_gz9) As count_gz9,Sum(count_gz10) As count_gz10,Sum(count_gz11) As count_gz11,Sum(count_gz12) As count_gz12,Sum(count_gz_other) As count_gz_other,Sum(count_gz_Sum) As count_gz_Sum,Avg(count_pjgz) As count_pjgz From gz_count Group By DwCode 

有子部门的部门
select *  from dwInfo where fatherCode+'.'+cstr(dwCode) in (select fatherCode from dwinfo Where not fatherCode is null group by fatherCode)