为什么我的回答不正确select_from_nobel_tutorial#14

时间:2015-12-18 22:06:15

标签: mysql sql

[更新] 最后弄清楚,我忘记将主题放入ORDER BY列

所有

我是SQL的新手,我想知道如何解决SQLZOO中的最后一个问题从nobel教程中选择最后一个问题:

http://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial

14.
The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1.
Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.

我认为应该是(在 MYSQL 版本中):

SELECT winner, subject
  FROM nobel
 WHERE yr=1984
 ORDER BY subject IN ('Physics','Chemistry'),winner

但它给了我错误:"Wrong answer. Some of the data is incorrect."

1 个答案:

答案 0 :(得分:1)

链接问题的解决方案如下: -

SELECT  winner, subject
  FROM nobel
 WHERE yr=1984
 ORDER BY subject IN ('Physics','Chemistry'), subject, winner

使用case语句将为您提供最终出现的物理和化学方面的内容。