--班级 SELECT sbr.organizationNo ,5 as schoolTypeGroupNo,'五、学前教育' as schoolTypeGroup,0 as schoolTypeGroupNo2,'' as schoolTypeGroup2,sbr.businessTypeNo,sbr.businessType ,sbr.ownertypeno ,sbr.ownerTypeGroup ,sbr.citycountrytypeno ,sbr.cityCountryGroup,sbr.structureType,sbr.populationGroup,sbr .isnation ,sbr.gatherregionc ,va.region_no ,case when sbr.businessTypeNo='111' then 1 else 0 end as isCount , sum(e + f + g + h) as classNo from schoolBusinessRelation sbr inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno inner join J211 as j on j.instanceid =it.instanceid inner join v_areainfo va on va.region_name =sbr.gatherregionc where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('111','119') 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,sbr.ownertypeno ,sbr.ownerTypeGroup ,sbr.citycountrytypeno ,sbr.cityCountryGroup,sbr.structureType,sbr.populationGroup,sbr .isnation ,sbr.gatherregionc ,va.region_no order by sbr.businessTypeNo,va.region_no ; --学生 SELECT sbr.organizationNo ,5 as schoolTypeGroupNo,'五、学前教育' as schoolTypeGroup,0 as schoolTypeGroupNo2,'' as schoolTypeGroup2,sbr.businessTypeNo,sbr.businessType ,sbr .isnation ,sbr.gatherregionc ,va.region_no ,case when sbr.businessTypeNo='111' then 1 else 0 end as isCount,sum( e+f+g+h) as zhaoshengNo,sum(k+l+m+n) as zaixiaoNo,sum(o) as biyeNo from schoolBusinessRelation sbr inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno inner join J311 as j on j.instanceid =it.instanceid and j.did in (5,6,7,8,9) inner join v_areainfo va on va.region_name =sbr.gatherregionc where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('111','119') and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 group by sbr.organizationNo,sbr.businessTypeNo,sbr.businessType ,sbr.isCount,sbr .isnation ,sbr.gatherregionc ,va.region_no order by sbr.businessTypeNo;