表的内容如下:
//查询单分数最高的人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;
本文深入探讨了SQL查询中常用的操作,包括最高分查询、总分排名、平均分筛选等,通过具体实例展示了如何高效地从数据库中获取所需信息。
331

被折叠的 条评论
为什么被折叠?



