日期:2014-05-18  浏览次数:20338 次

提问~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2)如求用一条SQL语句 查询出每门课都大于80分的学生姓名 
name kecheng fenshu  
张三 语文 81 
张三 数学 75 
李四 语文 76 
李四 数学 90 
王五 语文 81 
王五 数学 100 
王五 英语 90 
用这样的可以么。
1) select distinct name from table where not exists (select distinct name from table where fenshu <=80) 

2)select distinct name from table where not exists (select distinct name from table name=table.name where fenshu <=80) 
以上那个对?或是2个都不对?
最好比较一下错在那里。



------解决方案--------------------
1) select distinct name from table where not exists (select distinct name from table where fenshu <=80)

2)select distinct name from table where not exists (select distinct name from table name=table.name where fenshu <=80)
以上那个对?或是2个都不对? 
最好比较一下错在那里。
----------------------------------------
你第一个根本不对,第二个是对的但是语法写错了!改为
select distinct name from [table] As A where not exists (select name from [table] where name=A.name And fenshu<=80)