表的內容如下:
//查詢單分數最高的人ID
select stuid,max(score) from stu_select_class;
// 查詢各科總分2-3名的學生
select stuid, sum(score) from stu_select_class group by stuid limit 1,2;
//查詢每科的最高分學生
select classname,stuid,max(score) from stu_select_class group by classname;
//查詢總分低於140的學生
select stuid, sum(score) from stu_select_class group by stuid having sum(score)<140;
//查詢總平均分在60-80的學生
select stuid, avg(score) from stu_select_class group by stuid having avg(score) between 60 and 80;
//查詢。。。。的學生
select stuid, sum(score),avg(score) from stu_select_class group by stuid having sum(score)<140 and avg(score) <80;
//查詢總分。。的學生人數。
select distinct count( stuid) from stu_select_class group by stuid having sum(score)<140 and avg(score) <80;
//查詢。。。的學生人數
select count(distinct stuid) from stu_select_class where classname='english' and score <100;