select语句拼写

来源:百度知道 编辑:UC知道 时间:2024/06/14 16:32:38
问题是这样的,我有一个表,名叫student,里面有很多字段,包括籍贯,什么的,我现在想查询,怎么样才能返回下面的结果呢?小弟没多少分了,就给这点吧,大家别嫌少啊!
班级 总人数 男生 女生 党员 团员 群众 少数民族 吉林 辽宁 黑龙江 内蒙 陕西 河北(后面就是中国的省份)

select 班级,count(studentno) 总人数,(select count(studentno) from student where 性别='男') 男生,(select count(studentno) from student where 性别='女') 女生,(select count(studentno) from student where 政治面貌='党员') 党员,(select count(studentno) from student where 政治面貌='团员') 团员,(select count(studentno) from student where 政治面貌='群众') 群众,(select count(studentno) from student where 籍贯='少数民族') 少数民族,(select count(studentno) from student where 籍贯='吉林') 吉林,(select count(studentno) from student where 籍贯='辽宁') 辽宁,(select count(studentno) from student where 籍贯='黑龙将') 黑龙江,(select count(studentno) from student where 籍贯='内蒙古') 内蒙古,(select count(studentno) from student where 籍贯='陕西') 陕西,(select count(studentno) from student where 籍贯='河北') 河北
from student

select 班级,count(人数),男生,女生,党员,群众。。。from student

select sum(peson),sex,'政治面貌','民族','省' from student group by peson