SQLZOO练习题(4)
1.查询1960的所有获奖人
select yr, subject, winner from nobel where yr = 1950;
2.查找1962年获得诺贝尔文学奖的人
select Winner from nobel where yr=1962 and subject='Literature';
3.查找Albert Einstein获奖的年份和学科
select yr,subject from nobel where winner='Albert Einstein';
4.说出2000年以来“和平”获奖者的名字,包括2000年。
select Winner from nobel where yr>=2000 and subject='peace';
5.显示所有文学奖获奖者为1980年至1989年的所有信息,包括1980和1989。
select yr,subject,winner from nobel where subject='literature' and yr>=1980 and
yr<=1989;
6.显示总统选举获胜者的所有信息:
Theodore Roosevelt
Thomas Woodrow Wilson
Jimmy Carter
Barack Obama
select * from nobel where winner in ('Theodore Roosevelt','Woodrow Wilson','Jimmy Carter','Barack Obama');
7.查看获奖者名字是前面的字母是John的所有信息
select winner from nobel where winner like 'John%';
8.显示1980年物理获奖者和1984年化学获奖者的年份、学科和名字。
select * from nobel where yr=1980 and subject='physics ' or yr=1984 and subject='chemistry ';
9.显示1980年除化学和医学外的获奖者的年份、学科和姓名
select * from nobel where yr=1980 and subject not in('chemistry ','medicine');
10.展示早于在1910年之前,不包括1910年获得“医学奖”的年份、学科和姓名,以及在2004年之后,包括2004年的“文学奖”获奖者。
select * from nobel where yr<1910 and subject='Medicine' or yr>=2004 and subject='Literature';
11.找到PETER GRÜNBERG获奖的所有细节
select * from nobel where winner='PETER GRÜNBERG';
12.找到EUGENE O’NEILL获奖的所有细节
select * from nobel where winner="EUGENE O'NEILL";
13.列出获奖者、年份和科目,以“Sir”开头。先列出最近的获奖者按姓名顺序排列。
select winner,yr,subject from nobel where winner like 'Sir%' order by yr desc ,winner asc;
14.按主题和获奖者名称顺序显示1984年的获奖者和主题,但是把化学和物理列在最后。
表达式subject IN (‘chemistry’,‘physics’)可以用作值——它将是0或1。
select winner,subject from nobel where yr=1984 order by subject IN ('chemistry','physics')asc ,subject asc,winner asc;