Nobel Prizes: Aggregate functions

Using SUMCOUNTMAXAVGDISTINCT and ORDER BY.

表如下:

SELECT * FROM nobel;

select

 

 

1,Show the total number of prizes awarded.统计有多少个获奖者

SELECT COUNT(subject) FROM nobel

1b. List each subject - just once 列出每个奖项-只显示一次

SELECT DISTINCT(subject) FROM nobel

1c. Show the total number of prizes awarded for Physics显示物理学奖的总数量

SELECT COUNT(*) FROM nobel WHERE subject='Physics'

2a. For each subject show the subject and the number of prizes.为每个学科显示不同获奖者的数量

SELECT subject,COUNT(subject) FROM nobel GROUP BY subject

2b. For each subject show the first year that the prize was awarded显示为每个学科被授予奖项的第一年

SELECT subject,MIN(yr) FROM nobel GROUP BY subject

2c. For each subject show the number of prizes awarded in the year 2000.显示为每个学科奖项的数量在公元二○○○年。

SELECT subject,COUNT(subject) FROM nobel WHERE yr=2000 GROUP BY subject

3a. Show the number of different winners for each subject.显示每个学科不同获奖者的数量。

SELECT subject,COUNT(DISTINCT winner) FROM nobel  GROUP BY subject

3b. For each subject show how many years have had prizes awarded.为每个学科显示有多少年的奖项。

SELECT subject,COUNT(DISTINCT yr) FROM nobel GROUP BY subject

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值