diff --git a/BigDataSql/各阶段学校数量.sql b/BigDataSql/各阶段学校数量.sql new file mode 100644 index 00000000..7d05dfe6 --- /dev/null +++ b/BigDataSql/各阶段学校数量.sql @@ -0,0 +1,22 @@ + +SELECT businessType,count(1) as count +from schoolBusinessRelation sbr where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('211') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 +group by sbr.businessType + +union all + +SELECT businessType ,count(*) as c +from schoolBusinessRelation sbr +inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno +inner join J412 as j on j.instanceid =it.instanceid and j.did =1 +where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('311','312') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 +group by sbr.businessType + +union all + +SELECT sbr.businessType,count(1) as c +from schoolBusinessRelation sbr where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('341','342','345') and sbr.isLastYearCancel =0 +GROUP BY sbr.businessType + + +-- select * from codeschooltype where schooltypeno in ('211','218','312','345','321') \ No newline at end of file diff --git a/BigDataSql/城乡类型按学段师生比.sql b/BigDataSql/城乡类型按学段师生比.sql new file mode 100644 index 00000000..8471a745 --- /dev/null +++ b/BigDataSql/城乡类型按学段师生比.sql @@ -0,0 +1,66 @@ +select t1.a as stage,t1.citycountrygroup,sum(c1) as studentNo,sum(c2) as teacherNo from ( + select * from ( + SELECT '小学' as a,'学生' as b,sbr.cityCountryGroup,sum(j+k+l+m+n+o) as c1,0 as c2 + from schoolBusinessRelation sbr + inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno + inner join J312 as j on j.instanceid =it.instanceid and j.did in (1,37,38,39,40,41,42,43,44,45,46,47) + where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('211','218','219','312','345') and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 + group by sbr.cityCountryGroup + + union all + + SELECT '初中' as a,'学生' as b,sbr.cityCountryGroup,sum(i+j+k+l) as c1,0 as c2 + from schoolBusinessRelation sbr + inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno + inner join J313 as j on j.instanceid =it.instanceid and j.did in (1,36,37,38,39,40,41,42,43,44) + where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('311','312','319','321','341','345') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 + group by sbr.cityCountryGroup + + union all + + SELECT '高中' as a,'学生' as b,sbr.cityCountryGroup,sum(i+j+k) as c1,0 as c2 + from schoolBusinessRelation sbr + inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno + inner join J314 as j on j.instanceid =it.instanceid and did in (1,11,12,13,14,15,16,17,18,19) + inner join v_areainfo va on va.region_name =sbr.gatherregionc + where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('341','342','345','349') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 + group by sbr.cityCountryGroup + ) as t + + + union all + + + select * from ( + SELECT '高中' as a ,'老师' as b ,sbr.cityCountryGroup ,0 as c1, sum (F + G + H + I +j+k+l+ M + N ) as c2 + from schoolBusinessRelation sbr + inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno + inner join J422 as j on j.instanceid =it.instanceid and did in (22,23,24,25,26,27) + inner join v_areainfo va on va.region_name =sbr.gatherregionc + where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in ('341','342','345') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 + group by sbr.cityCountryGroup + + union all + + + SELECT '初中' as a ,'老师' as b ,sbr.cityCountryGroup ,0 as c1, sum (F + G + H + I +j+k+l+ M + N ) as c2 + from schoolBusinessRelation sbr + inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno + inner join J422 as j on j.instanceid =it.instanceid and did in (13,14,15,16,17,18) + inner join v_areainfo va on va.region_name =sbr.gatherregionc + where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in('311','312','321','341','345') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 + group by sbr.cityCountryGroup + + + union all + + SELECT '小学' as a ,'老师' as b ,sbr.cityCountryGroup ,0 as c1, sum (F + G + H + I +j+k+l+ M + N ) as c2 + from schoolBusinessRelation sbr + inner join instanceTable it on sbr.organizationNo =it.organizationNo and sbr.businesstypeno =it.businesstypeno + inner join J422 as j on j.instanceid =it.instanceid and did in (4,5,6,7,8,9) + inner join v_areainfo va on va.region_name =sbr.gatherregionc + where sbr.gatherRegionB ='长春市' and sbr.businessTypeNo in ('211','218','312','345') and sbr.isLastYearCancel =0 and sbr.recordyear =2019 and it.recordyear =2019 and j.recordyear =2019 + group by sbr.cityCountryGroup + + ) as t + ) as t1 group by a,citycountrygroup order by a,citycountrygroup \ No newline at end of file