SqlZoo.net习题答案:Using the SELECT statement.【nobel】
表结构: 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')