SQLZOO诺贝尔教程8
有人能帮我做这件事吗? 我是SQL新手,我真的不知道为什么我的答案是错误的:SQLZOO诺贝尔教程8,sql,Sql,有人能帮我做这件事吗? 我是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') 谢谢大家, 我自己解决了 select distinct yr from nobel wh
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')
谢谢大家,
我自己解决了
select distinct yr from nobel
where
subject='Physics' and yr not in
(select distinct yr from nobel where subject='Chemistry')
谢谢
我还找到了一种方法来揭示这些问题的答案,至少是其中的一些问题
只需将?answer=1附加到url,您就可以获得一个答案页面。
希望这能奏效 我通过这个查询得到了正确答案:
select * from nobel where (yr=1980 and subject='physics') or (yr=1984 and subject='chemistry');
从nobel中选择*
“物理”科目在哪里
和yr='1980'或科目='Chemistry'和yr='1984'
这很简单明了请尝试以下代码:
select yr,subject,winner
from nobel
where subject = 'Physics' and yr=1980
union
select yr,subject,winner
from nobel
where subject = 'Chemistry' and yr=1984
这是正确的答案,符合逻辑且可读:
SELECT yr,subject,winner
FROM nobel
WHERE (yr = 1980 and subject like 'Physics') + (yr = 1984 and subject like 'Chemistry')
您的答案与其他答案有何不同?我的答案中的要点是,我刚刚开始学习SQL,所以我用简单的语言编写了查询,正如问题所示,查询给出的结果是正确的。因此,对于初学者来说,我认为它是好的,否则它可能会变得更紧凑或更快。
SELECT yr,subject,winner FROM nobel WHERE yr=1980 AND subject NOT IN('Chemistry','Medicine')