SELECT from Nobel Tutorial

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

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

2、Show who won the 1962 prize for Literature.

select winner from nobel where yr=1962 and subject='literature';

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

select yr,subject from nobel where winner='albert einstein';

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

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

5、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、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、Show the winners with first name John

select winner from nobel where winner like 'John%';

8、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、Show the year, subject, and name of winners for 1980 excluding Chemistry and Medicine

select yr,subject,winner from nobel
where yr=1980 and subject not in ('chemistry','medicine');

10、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 yr,subject,winner from nobel
where (subject='medicine' and yr<1910)
or subject='literature' and yr>=2004;

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

select * from nobel
where winner='PETER GRÜNBERG';

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

select * from nobel
where winner='eugene O\'NEILL';

13、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、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 ('Physics','Chemistry'),subject,winner;

总结:

1、字符串本身有引号‘’时,应该使用转义字符\进行转义。

MySQL练习题--sqlzoo刷题2的更多相关文章

  1. MySQL练习题--sqlzoo刷题

    首先查看world表的字段: name continent area population gdp capital tld flag SELECT * FROM world: 2.显示人口至少为2亿的 ...

  2. sqlzoo刷题 SELECT from Nobel Tutorial

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

  3. mysql刷题(不定时更新)

    面试阶段大家基本都会问一些mysql的题,具体的高深理论以后再慢慢补充,但是刷题是不可避免的,下面直接上货 创建/删除表和索引系列 创建表 CREATE TABLE if not exists `te ...

  4. mysql刷题笔记

    近期,为提升自己的工程能力,在休息时常通过刷题来回顾一下基础性知识. 于是选择了牛客网上的mysql知识题库练手,过程中,主要遇到了几个比较有意思的题,记录下来,方便回顾. 题1:SQL29 计算用户 ...

  5. MySQL练习题参考答案

    MySQL练习题参考答案 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 思路: 获取所有有生物课程的人(学号,成绩) - 临时表 获取所有有物理课程的人(学号,成绩) - 临时表 根据[ ...

  6. s15day12作业:MySQL练习题参考答案

    MySQL练习题参考答案   导出现有数据库数据: mysqldump -u用户名 -p密码 数据库名称 >导出文件路径           # 结构+数据 mysqldump -u用户名 -p ...

  7. python 全栈开发,Day65(MySQL练习题,参考答案)

    一.MySQL练习题 一.表关系 请创建如下表,并创建相关约束 二.操作表 1.自行创建测试数据 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号.ps:针对的是自己的生物成绩比物理成绩高,再 ...

  8. 湾区求职分享:三个月刷题拿到 Google offer,欢迎踊跃提问

    本文仅以个人经历和个人观点作为参考.如能受益,不胜荣幸. 本文会不断的修正,更新.希望通过大家的互动最后能写出一份阅者受益的文章. 本文纯手打,会有错别字,欢迎指出,虚心接受及时更改. 小马过河,大牛 ...

  9. mysql 练习题答案

    一 题目 1.查询所有的课程的名称以及对应的任课老师姓名 2.查询学生表中男女生各有多少人 3.查询物理成绩等于100的学生的姓名 4.查询平均成绩大于八十分的同学的姓名和平均成绩 5.查询所有学生的 ...

随机推荐

  1. 0xC0000005: 写入位置 0x00000000 时发生访问冲突的解决办法(转)

    上面的意识就是你吧值付给了不该赋给的变量,或者说你把值付给了不能付给的变量(或者常量) ()最简单也最直接的错误可能就是scanf()的问题,我们都知道输入的时候都是scanf("%格式&q ...

  2. IIS配置Windows防火墙允许外部访问

    控制面板-Windows防火墙-高级设置-入站规则 在入站规则窗口中找到“BranchCache内容检索(HTTP-In)”选项并启用此规则. 这时候远程用户通过网站地址即可访问站点程序. 但是如果远 ...

  3. sass-loader屡次安装不生效的问题

    报错信息: npm WARN sass-loader@8.0.0 requires a peer of webpack@^4.36.0 but none is installed. You must ...

  4. CDN技术之--集群服务与负载均衡

    Web集群是由多个同时运行同一个web应用的服务器组成,在外界看来就像一个服务器一样,这多台服务器共同来为客户提供更高性能的服务.集群更标准的定义是:一组相互独立的服务器在网络中表现为单一的系统,并以 ...

  5. HTML—学习笔记

    1 .表格 <br/>换行 <p> align top<img src="./julizi.png" align="top" &g ...

  6. C# 语法特性

    C# 2.0 1.泛型(Generics). 2.泛型方法.泛型委托.泛型接口. 3.泛型约束(constraints). 4.部分类(partial). 5.匿名方法. C#3.0/C#3.5 1. ...

  7. C# Winform版批量压缩图片程序

    需求 上周,领导给我分配了一个需求:服务器上的图片文件非常大,每天要用掉两个G的大小的空间,要做一个自动压缩图片的工具处理这些大图片.领导的思路是这样的: 1)打开一个图片,看它的属性里面象素是多少, ...

  8. 框架-.NET:ASP.NET Core

    ylbtech-框架-.NET:ASP.NET Core ASP.NET Core是一个免费且开放源代码的Web框架,以及由微软和社区开发的下一代ASP.NET.它是一个模块化框架,既可以Window ...

  9. HTML-参考手册: HTML 符号实体

    ylbtech-HTML-参考手册: HTML 符号实体 1.返回顶部 1. HTML 符号实体 本字符实体参考手册包括了数学符号.希腊字符.各种箭头记号.科技符号以及形状. 注释: 实体名称对大小写 ...

  10. C++构造函数异常(一)

    C++ 构造函数的异常是一个比较难缠的问题,很多时候,我们可能不去考虑这些问题,如果被问到,有人可能会说使用RAII管理资源. 但你真的考虑过如果构造函数失败了,到底会发生什么吗,前面构造成功的成员. ...