--did: --其中:女2 --正高级3 --副高级4 --中 级5 --初 级6 --未定职级7 SELECT sbr.organizationNo ,1 as schoolTypeGroupNo,'一、高中阶段' as schoolTypeGroup,2 as schoolTypeGroupNo2,'(二)中等职业学校' as schoolTypeGroup2 ,sbr.businessTypeNo,case when sbr.businessTypeNo in ('368','369') then '其他机构(班)' else sbr.businessType end as businessType , sbr.isCount ,sum(e+f+g+h+i+j+k+l) as teacherNo,sum(e) as teacherNo2,sum(f) as teacherNo3,sum(g) as teacherNo4,sum(h) as teacherNo5,sum(i) as teacherNo6 ,sum(j) as teacherNo7,sum(k) as teacherNo8,sum(l) as teacherNo9,did from schoolBusinessRelation sbr inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno inner join Z423 as j on j.instanceid =it.instanceid and j.did between 2 and 7 where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('362','364','365','369','361','363') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 group by sbr.organizationNo,sbr.businessTypeNo,sbr.businessType ,sbr.isCount,did order by sbr.businessTypeNo;