--查询学生的个数
select count(性别) as 男生 from xs where 性别=1
--总学分最高的人的姓名
select max(总学分)as 最高分,count(姓名) as 总人数,avg(总学分) as 平均分 ,sum(总学分) as sum总学分,min(总学分) as 最低分 from xs
select * from xs
--每个专业多少人?
select count(*)总人数,专业名 from xs
group by 专业名
--查询一下计算机专业的男生他们的平均总学分
select 专业名,avg(总学分) as 平均总学分 from xs
where 专业名='计算机' and 性别='1'
group by 专业名
--查询所有专业的平均分,并按照他们的总学分高低来排序
select 专业名,sum(总学分)as 总学分 from xs
group by 专业名 having sum(总学分)>500
order by sum(总学分) desc
--按性别分组,查看计算机专业学生的平均总学分,显示平均总学分大于49的分组的人数,平均分,及所在性别组
select count(*) as 人数,avg(总学分) as 平均总学分,性别
from xs
where 专业名='计算机'
group by 性别
having avg(总学分)>49
--查询每个专业中,总学分最高的男生和女生的总学分
select 专业名,max(总学分) as 最高分,性别
from xs
group by 专业名,性别 --- with rollup --在查询结果中添加小计
--查询各个专业中男女生各多少人?
select count(*) as 总人数,专业名,性别 from xs
group by 专业名,性别
--查询所有学生中男生女生最高成绩?
select 性别,max(总学分) as 最高分 from xs
group by 性别