【Tips】
- sqlzoo官网链接:
- 每个系列开头介绍所用表及其信息
- 每道题均测试通过,含有题目描述、代码和结果
- 题目为自己简写,最好在官网查看具体题目
- 部分测试结果不完整,仅为一部分截图
SELECT from Nobel练习链接:
- yr:获奖年份
- subject:获奖类别
- winner:获奖者
1.查询显示1950年诺贝尔奖的奖项资料
SELECT * FROM nobel WHERE yr = 1950
SELECT winner FROM nobel WHERE yr = 1962 AND subject = 'Literature'
SELECT yr,subject FROM nobel WHERE winner='Albert Einstein'
SELECT winner FROM nobel WHERE yr>=2000 AND subject='Peace'
SELECT * FROM nobel WHERE subject ='Literature' AND yr BETWEEN 1980 AND 1989')
SELECT * FROM nobel WHERE winner IN ('Theodore Roosevelt', 'Woodrow Wilson', 'Jimmy Carter')
SELECT winner FROM nobel WHERE winner LIKE 'John%'
SELECT * FROM nobel WHERE (yr=1980 AND subject='physics') OR (yr=1984 AND subject='chemistry')
SELECT * FROM nobel WHERE subject NOT IN ('Chemistry','Medicine') AND yr=1980
SELECT * FROM nobel WHERE (yr<1910 AND subject='Medicine') OR (yr>=2004 AND subject='Literature')
SELECT * FROM nobel WHERE winner='PETER GRÜNBERG'
SELECT * FROM nobel WHERE winner='EUGENE O''NEILL' --使用两个单引号表示文本中的一个单引号
SELECT winner,yr,subject FROM nobel WHERE winner LIKE 'Sir%' ORDER BY yr DESC,winner
SELECT winner,subject FROM nobel WHERE yr=1984 ORDER BY subject IN ('Chemistry','Physics'),subject,winner