SQL查询语句。求人帮助!

来源:百度知道 编辑:UC知道 时间:2024/06/03 20:46:53
有这样一个表 姓名 科目 成绩 3个字段
要求写一个SQL语句
查询出所有成绩都合格的人的姓名 ! 是所有成绩哦
distinct 姓名
是按你写的这样用? 还是distinct(姓名)?

大哥没有分啊

select distinct a.姓名
from 表 a
where not exists (
select 1
from 表 b
where b.姓名=a.姓名
and b.成绩 < 60
)

这样就可以了!谢谢

PS:改了一下,没看清楚题目,按我写的直接用就行了。代码没问题,不要想的太复杂。a,b是表别名。

SELECT distinct 姓名 FROM #table where 成绩>60

select distinct name from table where examscores>=60