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

本文提供了一系列关于Nobel奖数据的SQL查询练习,包括按年份筛选获奖者、查询特定领域的获奖情况以及复杂的数据筛选技巧。通过实际操作,读者可以提升SQL技能并加深对数据库查询的理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

习题地址: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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值