sql疑难杂症
数据库如下
name kc fs
A 语文 65
A 数学 66
B 语文 55
B 数学 86
C 语文 64
C 数学 66
A 英语 66
用一条sql语句查出所有kc的fs大于60的学生的姓名
[解决办法]
create table student(name varchar(10),kc varchar(10),fs int)
insert into student
select 'A ', '语文 ',65
union all select 'A ', '数学 ',66
union all select 'B ', '语文 ',55
union all select 'B ', '数学 ',86
union all select 'C ', '语文 ',64
union all select 'C ', '数学 ',66
union all select 'A ', '英语 ',66
select name
from student
group by name
having count(*)=(select count(*) from student t where student.name=t.name and t.fs> 60)
[解决办法]
暈,理解錯了。
Select * From TableName A
Where Not Exists(Select * From TableName Where name = A.name And fs <= 60)
sql疑难杂症解决方案
sql疑难杂症数据库如下namekcfsA语文65A数学66B语文55B数学86C语文64C数学66A英语66用一条sql语句查出所有
