第1关 对查询结果进行排序
--#请在此处添加实现代码
--########## Begin ##########
--########## 查询1班同学的所有信息以成绩降序的方式显示结果 ##########
select stu_id,class_id,name,score
from tb_score
where class_id = 1
group by tb_score.stu_id,tb_score.class_id
order by tb_score.score desc;
--########## End ##########
第2关 分组查询
--#请在此处添加实现代码
--########## Begin ##########
--########## 对班级名称进行分组查询 ##########
select class_id from tb_class group by tb_class.class_id;
--########## End ##########
第3关 GROUP BY 与 聚合函数
--#请在此处添加实现代码
--########## Begin ##########
--#1.查询表中2,3,4年级中分别男女的总人数
select gradeId,sex,count(*)
from student
where gradeId in (2,3,4)
group by gradeId,sex;
--########## End ##########
--#请在此处添加实现代码
--########## Begin ##########
--#1.查询表中至少有两门课程在90分以上的学生信息
select sno,count(*)from tb_grade
where score >= 90
group by sno
having count(pno) >= 2;
--#2.查询表中平均成绩大于90分且语文课在95分以上的学生信息
select sno,avg(score) from tb_grade where sno in (select sno from tb_grade where score >= 95 and pno = '语文' )
group by sno having avg(score) >= 90;
--########## End ##########