时间:2021-07-01 10:21:17 帮助过:7人阅读
方法1: 找出有科目没有达到80分的姓名,然后过滤
1 select distinct name 2 from score a 3 where not exists(select 1 from score where a.name=name and score<80)
1 select distinct name 2 from score 3 where name not in (select name from score where score<80)
方法2: 通过分组后过滤的方式
1 select name 2 from score 3 group by name 4 having COUNT(1)=SUM(case when score>=80 then 1 else 0 end)
1 select name 2 from score 3 group by name 4 having MIN(score)>=80
结果:
name
JimGreen
LiLei
在记录较少(9条)的情总下 以上四种方式的执行计划(SQL2008)用时比例为
14:14:11:11
用一条SQL语句 查询出每门课程都大于80分的学生姓名" 的实现方式
标签: