We continue practicing simple SQL queries on a single table.

This tutorial is concerned with a table of Nobel prize winners:

nobel(yr, subject, winner)

Using the SELECT statement.

1、Winers from 1950

检索1950年的诺贝尔奖信息。

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

SELECT yr,subject,winner
FROM nobel
WHERE yr=1950;

2、1962 literature

显示1962年诺贝尔文学奖得主信息。

Show who won the 1962 prize for Literature.

SELECT winner
FROM nobel
WHERE yr=1962 AND subject ='Literature';

3、Albert Einstein

显示爱因斯坦得诺贝尔奖的时间和奖项。

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

4、Recent Peace Prize

显示自2000年(包含2000)年至今,诺贝尔和平奖的得主。

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

SELECT winner
FROM nobel
WHERE subject='Peace' AND yr>=2000;

5、Literature in 1980's

显示从1980-1989年诺贝尔文学奖的所有信息。

Show all details (yrsubjectwinner) of the Literature prize winners for 1980 to 1989 inclusive.

SELECT *
FROM nobel
WHERE subject='Literature' AND yr BETWEEN 1980 AND 1989;

6、Only presidents

显示总统得主‘西奥多·罗斯福’,‘伍德罗·威尔逊’,‘吉米·卡特’,‘巴拉克·奥巴马’的所有信息。

Show all details of the presidential winners:

  • Theodore Roosevelt
  • Woodrow Wilson
  • Jimmy Carter
  • Barack Obama
SELECT *
FROM nobel
WHERE winner IN('Theodore Roosevelt','Woodrow Wilson','Jimmy Carter','Barack Obama');

7、John

显示名为‘John’的诺贝尔奖得主姓名。

Show the winners with first name John

SELECT winner
FROM nobel
WHERE winner LIKE 'John%';

8、Chemistry and Physics from different years

显示1980年诺贝尔物理学和1984年诺贝尔化学奖得主的年份,奖项,姓名。

Show the year, subject, and name of Physics winners for 1980 together with the Chemistry winners for 1984.

SELECT yr,subject,winner
FROM nobel
WHERE subject='Physics' AND yr=1980 OR subject='Chemistry' AND yr=1984;

9、Exclude Chemists and medics

显示1980年诺贝尔除化学和药学之外的所有信息。

Show the year, subject, and name of winners for 1980 excluding Chemistry and Medicine

SELECT * FROM nobel
WHERE yr=1980 AND subject NOT IN ('Chemistry','Medicine');

10、Early medicine,Later Literature

显示1910年以前(不包含1910年)医药学得奖信息和2004年后(包含2004年)的文学奖得奖信息。

Show year, subject, and name of people who won a 'Medicine' prize in an early year (before 1910, not including 1910) together with winners of a 'Literature' prize in a later year (after 2004, including 2004)

SELECT * FROM nobel
WHERE subject='Medicine' AND yr <1910 OR subject='Literature' AND yr>=2004;

11、Umlaut

显示PETER GRÜNBERG的得奖信息。

Find all details of the prize won by PETER GRÜNBERG

SELECT * FROM nobel
WHERE winner='PETER GRÜNBERG';

12、apostrophe

显示EUGENE O'NEILL的得奖信息。

Find all details of the prize won by EUGENE O'NEILL

-- 字符串中出现单引号时,要加一个单引号,或者\
SELECT * FROM nobel
WHERE winner='EUGENE O''NEILL';

13、Knights of the realm

Knights in order

罗列以‘Sir’开头的得奖者姓名,年份,得奖项信息,年份按照最近排序,然后按照名字排序

List the winners, year and subject where the winner starts with Sir. Show the the most recent first, then by name order.

SELECT winner,yr,subject
FROM nobel
WHERE winner LIKE 'Sir%'
ORDER BY yr DESC,winner;

14、Chemistry and Physics Last

The expression subject IN ('Chemistry','Physics') can be used as a value - it will be 0 or 1.

Show the 1984 winners and subject ordered by subject and winner name; but list Chemistry and Physics last.

SELECT winner, subject FROM nobel
WHERE yr=1984
ORDER BY subject IN('Chemistry','Physics'),subject,winner;

SQLZOO练习二--SELECT from Nobel Tutorial的更多相关文章

  1. sqlzoo刷题 SELECT from Nobel Tutorial

    SELECT from Nobel Tutorial 1.Change the query shown so that it displays Nobel prizes for 1950. SELEC ...

  2. SELECT from Nobel Tutorial

    02.SELECT from Nobel Tutorial 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.Change the quer ...

  3. sqlzoo - SELECT from WORLD Tutorial 答案

    01.SELECT from WORLD Tutorial 01.显示所有国家的名称,大洲和人口. SELECT name, continent, population FROM world; 02. ...

  4. SQLZOO网页中SQL的答案(SELECT from nobel篇)

    SELECT from nobel篇 1. 更改查詢以顯示1950年諾貝爾獎的獎項資料. 答案: SELECT yr, subject, winner FROM nobel WHERE yr = 19 ...

  5. {MySQL的逻辑查询语句的执行顺序}一 SELECT语句关键字的定义顺序 二 SELECT语句关键字的执行顺序 三 准备表和数据 四 准备SQL逻辑查询测试语句 五 执行顺序分析

    MySQL的逻辑查询语句的执行顺序 阅读目录 一 SELECT语句关键字的定义顺序 二 SELECT语句关键字的执行顺序 三 准备表和数据 四 准备SQL逻辑查询测试语句 五 执行顺序分析 一 SEL ...

  6. sqlzoo练习答案--SELECT within SELECT Tutorial

    This tutorial looks at how we can use SELECT statements within SELECT statements to perform more com ...

  7. SQLZOO练习三--SELECT within SELECT Tutorial

    This tutorial looks at how we can use SELECT statements within SELECT statements to perform more com ...

  8. (十二)select()函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET

    select函数用于在非阻塞中,当一个套接字或一组套接字有信号时通知你,系统提供select函数来实现多路复用输入/输出模型,原型:int select(int maxfd,fd_set *rdset ...

  9. SQL 语句 (二) --- SELECT

    1 完整句法: SELECT [ ALL | DISTINCT TOP n [] WITH TIES select_list [INTO [new_table_name] ] [FROM {table ...

随机推荐

  1. Bootstrap Blazor 模板使用(一)Layout 组件

    原文链接:https://www.cnblogs.com/ysmc/p/16197223.html BootstrapBlazor 官网地址:https://www.blazor.zone Boots ...

  2. Windows与Linux如何实现相互远程桌面连接?

    今天跟大家一起讨论下,利用Windows自带的远程桌面连接工具,实现远程Linux桌面及在Linux系统中远程Windows桌面 一.Windows远程Linux桌面 1)本次实验以CentOS 7. ...

  3. Kubernetes 从入门到进阶实战教程 (2021 最新万字干货版)

    作者:oonamao 毛江云,腾讯 CSIG 应用开发工程师原文:来源腾讯技术工程,https://tinyurl.com/ya3ennxf 写在前面 笔者今年 9 月从端侧开发转到后台开发,第一个系 ...

  4. drf-Serializers

    What is serializers? serializers主要作用是将原生的Python数据类型(如 model querysets )转换为web中通用的JSON,XML或其他内容类型. DR ...

  5. 【DIY】【CSAPP-LAB】深入理解计算机系统--datalab笔记

    title: 前言 <深入理解计算机系统>一书是入门计算机系统的极好选择,从其第三版的豆瓣评分9.8分可见一斑.该书的起源是卡耐基梅龙大学 计算机系统入门课(Introduction to ...

  6. ElasticSearch7.3学习(二十五)----Doc value、query phase、fetch phase解析

    1.Doc value 搜索的时候,要依靠倒排索引: 排序的时候,需要依靠正排索引,看到每个document的每个field,然后进行排序. 所谓的正排索引,其实就是doc values. 在建立索引 ...

  7. 【数据库】MYSQL如何添加索引

    1.使用ALTER TABLE语句创建索性 应用于表创建完毕之后再添加. 1.1语法 ALTER TABLE 表名 ADD 索引类型 (unique,primary key,fulltext,inde ...

  8. 微信小程序避坑指南——input框里的图标在部分安卓机里无法点击的问题

    问题场景: 下图中的显隐密码和验证码均为包裹在 input标签 中的 image标签, 但在开发测试中发现点击不了这俩个image标签,因为是被input标签的padding挡住了. 解决方法:将im ...

  9. einsum函数介绍-张量常用操作

    einsum函数说明 pytorch文档说明:\(torch.einsum(equation, **operands)\) 使用基于爱因斯坦求和约定的符号,将输入operands的元素沿指定的维数求和 ...

  10. spring boot 在控制台打印banner

    转自 SpringBoot系列--花里胡哨的banner.txt - huanzi-qch - 博客园 (cnblogs.com) <div id="cnblogs_post_body ...