分类: Mysql/postgreSQL
2008-06-16 01:51:02
--> 测试数据: # if object_id('tempdb.dbo.#') is not null drop table # create table # (studentname varchar(5),classname varchar(7),grade int) insert into # select 'mike','english',65 union all select 'mike','math',75 union all select 'Jerry','english',80 union all select 'Jerry','math',68 union all select 'Lida','english',88 union all select 'Lida','chinese',77 union all select 'Lida','math',90 select * from # a where not exists (select 1 from # where studentname=a.studentname and grade<75) /* 求出各科成绩都大于75分的学生。即得到如下结果 studentname classname grade Lida english 88 Lida chinese 77 Lida math 90 */
chinaunix网友2009-04-09 18:33:58
是不是应该这样啊 select * from #cj where studentname not in (select dictinct studentname from #cj where grade<=75)
chinaunix网友2009-02-12 11:31:24
select * from #cj where studentname not in (select studentname from #cj where grade<=75)
chinaunix网友2008-06-17 10:56:38
想了一下,弄了另外一个解决办法 select * from test2 where studentname not in(select studentname from test2 group by studentname having min(grade) <75);