SqlZoo.net习题答案:Using the SELECT statement.【nobel】

时光毁灭记忆、已成空白 提交于 2019-11-26 18:36:33

习题地址:http://sqlzoo.net/1b.htm

 

 

表结构:  nobel(yr, subject, winner)

 

 

1a.Change the query shown so that it displays Nobel prizes for 1950.

select *
from nobel 
where yr = 1950

 

 

1b.Show who won the 1962 prize for Literature.

select winner 
from nobel 
where yr = 1962 and subject = 'Literature'

 

 

2a.Show the year and subject that won 'Albert Einstein' his prize.

select yr, subject 
from nobel 
where winner = 'Albert Einstein'

 

2b.Give the name of the 'Peace' winners since the year 2000, including 2000.

select winner
from nobel 
where subject = 'Peace' and yr >= 2000

 

2c.Show all details (yr, subject, winner) of the Literature prize winners for 1980 to 1989 inclusive.

select * 
from nobel 
where subject = 'Literature' and yr >= 1980 and yr <= 1989

 

2d.Show all details of the presidential winners: ('Theodore Roosevelt', 'Woodrow Wilson', 'Jed Bartlet', 'Jimmy Carter')

select * 
from nobel 
where winner in ('Theodore Roosevelt', 'Woodrow Wilson', 'Jed Bartlet', 'Jimmy Carter')

 

2e.Show the winners with first name John

select winner 
from nobel 
where winner like 'John%'

 

3a.In which years was the Physics prize awarded but no Chemistry prize. (WARNING - this question is way too hard for this level, you will need to use sub queries or joins).

select distinct 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')

 

 

 

转载于:https://www.cnblogs.com/Leo-Forest/archive/2012/06/01/2531319.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!