sql面试题:查询各科成绩都不低于80分的学生

96 阅读1分钟

如下学生成绩表,查询各科成绩都不低于80分的学生。表名 tb

stucoursescore
张三数学90
张三语文80
张三英语70
李四数学90
李四语文87
李四英语90
王五数学88
王五语文78
王五英语89

解答思路: 1、常规,查询记录中stu不在低于80的stu中的;

select stu from tb where stu not in (select distinct stu from tb where score<80);

2、统计函数;

select stu from tb group by stu having min(score)>80;