关于数据库的查询问题

来源:百度知道 编辑:UC知道 时间:2024/05/27 09:29:23
有这么一张表:
---ID---名字---科目---成绩
1 aa 语文 23
2 aa 数学 43
3 bb 语文 87
4 bb 数学 60
5 cc 语文 88
6 cc 数学 89
7 cc 英语 90

请用SQL语句查询出每科成绩大于80分的同学。。。
是要科都大于80分以上的 学生姓名

select distinct 名字 from table where 名字 in (select 名字 from table where 成绩>80 group by 名字 having count(名字)='这里填总科目数')

这个语句不行?有qq吗?

select * from table where 成绩>80 order by id

不考虑重名情况
select distinct 名字 from table where 名字 in (select 名字 from table where 成绩>80 group by 名字 having count(名字)='科目数')

考虑重名
还是算了吧。。

select 名字 from TableName where 成绩>80