--did: --正高级3 --副高级4 --中级5 --助理级6 --员级 无 --未定职级7 --女 2 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(g+h+i+j+k+l) as jzgNo,sum(g) as teacherNo,sum(h) as teacherNo2,sum(i) as teacherNo3,sum(j) as teacherNo4,sum(k) as teacherNo5,sum(l) as teacherNo6,sum(m) as teacherNo7,did from schoolBusinessRelation sbr inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno inner join Z411 as j on j.instanceid =it.instanceid and j.did in (2,3,4,5,6,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; --聘任制 --正高级10 --副高级11 --中级12 --助理级13 --员级 无 --未定职级14 --女 9 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(g+h+i+j+k+l) as jzgNo,sum(g) as teacherNo,sum(h) as teacherNo2,sum(i) as teacherNo3,sum(j) as teacherNo4,sum(k) as teacherNo5,sum(l) as teacherNo6,sum(m) as teacherNo7,did from schoolBusinessRelation sbr inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno inner join Z411 as j on j.instanceid =it.instanceid and j.did in (9,10,11,12,13,14) 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;