sqlzoo(三)SELECT from Nobel Tutorial


12 Find all details of the prize won by EUGENE O'NEIL
单引号:
You can't put a single quote in a quote string directly. You can use two single quotes within a quoted string.

select * from nobel where winner = 'EUGENE O''NEILL'

13 Knights in order

List the winners, year and subject where the winner starts with Sir. Show the the most recent first, then by name order

select winner, yr, subject from nobel where winner like 'Sir%' order by yr desc,winner

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.
按网上的答案 in处一直报错,修改如下,但并没有显示正确

select winner, subject  from nobel
where yr=1984
order by case when  subject IN ('Chemistry','Physics') then 1 else 0 end, subject ,winner 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容