SQLZOO诺贝尔教程#8

时间:2014-03-31 21:44:59

标签: sql

http://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial

有人可以给我一些帮助来做#8吗? 我是SQL的新手,我真的不知道为什么我的答案是错的:

select yr from nobel where 
yr in (select distinct yr from nobel where subject='Physics') 
and 
yr not in (select distinct yr from nobel where subject='Chemistry')

由于

6 个答案:

答案 0 :(得分:1)

全部, 我自己解决了。

select distinct yr from nobel 
where 
subject='Physics' and yr not in 
(select distinct yr from nobel where subject='Chemistry')

由于

我也找到了一种方法来揭示这些问题的答案(至少其中一些) 只需将?answer = 1 附加到网址,您就可以获得答案页面。 希望这有效!

答案 1 :(得分:0)

我通过这个查询得到了正确的答案:

select * from nobel where (yr=1980 and subject='physics') or (yr=1984 and subject='chemistry');

答案 2 :(得分:0)

SELECT * FROM nobel  WHERE(subject ='物理'   AND yr ='1980')或(subject ='Chemistry'和yr ='1984')

这很简单直接

答案 3 :(得分:0)

试试这段代码:

{1}

答案 4 :(得分:0)

SELECT yr,subject,winner FROM nobel WHERE yr=1980 AND subject NOT IN('Chemistry','Medicine')

答案 5 :(得分:-1)

这是正确的答案,既合乎逻辑又以可读的形式:

SELECT yr,subject,winner
FROM nobel
WHERE (yr = 1980 and subject like 'Physics') + (yr = 1984 and subject like 'Chemistry')