1 数据集介绍


在线运行:

https://sqlzoo.net/wiki/SELECT_basics

2 练习题

2.1 知识储备

  • 字符串需要使用单引号
  • 使用in可以检查某一项是否位于某个列表内
  • 使用between XXX and XXX可以检查某一项是否位于某个范围内

2.2 练习

show the population of Germany
select population from world where name = 'Germany';
Show the name and the population for ‘Sweden’, ‘Norway’ and ‘Denmark’.
select name,population from world where name in ('Sweden','Norway','Denmark');
show the country and the area for countries with an area between 200,000 and 250,000
select name,area from world where area between 200000 and 250000;

3 十三道和world表关联的sql语句

https://sqlzoo.net/wiki/SELECT_from_WORLD_Tutorial

1

SELECT name, continent, population FROM world

2

select name from world where population > 200000000;

3

select name, gdp/population from world where population > 200000000;

4

select name,population/1000000 from world where continent = 'South America';

5

select name,population from world where name in ('France','Germany','Italy');

6

select name from world where name like '%United%';

7

select name,population,area from world where area > 3000000 or population > 250000000;

8

select name,population,area from world where area > 3000000 and population < 250000000 or area < 3000000 and population > 250000000;

9

select name,round(population/1000000,2),round(gdp/1000000000,2) from world where continent = 'South America';

10

select name,round(gdp/population,-3) from world where gdp > 1000000000000;

11

SELECT name,capital FROM world
WHERE LEN(name)=LEN(capital)

12

select name,capital from world where left(name,1) = left (capital,1) and name <> capital;

13

select name from world where name like '%a%' and name like '%e%' and name like '%i%' and name like '%o%' and name like '%u%' and name not like '% %';

4 十四道和nobel表关联的sql语句

https://sqlzoo.net/wiki/SELECT_from_Nobel_Tutorial

1

select * from nobel where yr=1950;

2

SELECT winnerFROM nobelWHERE yr = 1962AND subject = 'literature'

3

select yr,subject from nobel where winner='Albert Einstein'

4

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

5

select * from nobel where yr between 1980 and 1989 and subject = 'literature'

6

select * from nobel where winner in ('Theodore Roosevelt','Woodrow Wilson','Jimmy Carter','Barack Obama');

7

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

8

select yr,subject,winner from nobel where (yr=1980 and subject='physics') or (yr=1984 and subject='chemistry')

9

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

10

select yr,subject,winner from nobel where (subject='Medicine' and yr < 1910) or (subject='Literature' and yr>=2004)

11

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

12

select * from nobel where winner = 'EUGENE O''NEILL'

13

select winner,yr,subject from nobel where winner like 'Sir%' order by yr desc,winner asc;

14

应该是正确答案,但是不对,不知道为啥:

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

sql select 基础用法相关推荐

  1. [渗透攻防] 二.SQL MAP工具从零解读数据库及基础用法

    这是最近学习渗透和网站攻防的文章,希望能深入地学习这部分知识,自己作为一个初学者,前一篇文章从数据库原理解读了防止SQL注入,这篇文章通过SQLMAP工具简单介绍SQL注入及用法.自己仍在慢慢探索网络 ...

  2. SQL语句 SELECT LIKE用法详解

    在SQL结构化查询语言中,LIKE语句有着至关重要的作用. LIKE语句的语法格式是:select * from 表名 where 字段名 like 对应值(子串),它主要是针对字符型字段的,它的作用 ...

  3. exists sql用法_彻底弄懂sql select各种查询用法

    相信很多人和我一样,学习sql 就是记忆各种sql的语法,但是记了一大堆的语法,在遇到实际查询问题时又无从下手的感觉.本文主要是针对sql 中select用法的总结,用于帮助大家解决记了相关语法却不知 ...

  4. sql中变量用法_SQL变量:基础和用法

    sql中变量用法 In this article, we will learn the notions and usage details of the SQL variable. In SQL Se ...

  5. sql初学者指南_初学者SQL示例:SQL SELECT语句的用法

    sql初学者指南 SQLSELECT statements are used to retrieve data from the database and also, they populate th ...

  6. SQL语句基础4/select查询语句练习

    SQL语句基础4 注:除指明表格之外所有的数据来源于Oracle数据库自带的SCOTT用户表. 1. 表连接(99语法) 1.1 内连接 cross join语法:cross join即交叉连接,用于 ...

  7. sql中几种删除语句的比较和基础用法

    sql中有三种删除语句 delete.drop.truncate 1.delete 基础用法:delete from table(表名) [where] 用法理解:用于删除有明确定义的数据或者整个表的 ...

  8. SQL基础---SQL SELECT DISTINCT 语句

    SQL SELECT DISTINCT 语句 本章讲解 SELECT DISTINCT 语句. SQL SELECT DISTINCT 语句 在表中,可能会包含重复值.这并不成问题,不过,有时您也许希 ...

  9. SQL SELECT DISTINCT 语句 用法

    SQL SELECT DISTINCT 语句 在表中,可能会包含重复值.这并不成问题,不过,有时您也许希望仅仅列出不同(distinct)的值. 关键词 DISTINCT 用于返回唯一不同的值. 语法 ...

最新文章

  1. 【第23周复盘】懒癌犯了,拖到今天!
  2. 自动化测试系列-自动化测试框架那些事儿
  3. 用C#使用HttpWebRequest Post数据时如何保持Session
  4. poj 3468 线段树
  5. getjsonobject字符串解析出错_【干货分享】达梦DISQL工具使用解析之 DISQL环境变量设置...
  6. dvwa如何打开_一篇文章让你搭建自己的Web安全测试平台(Dvwa)
  7. 构建linux根文件系统
  8. s3c2440启动文件详细分析
  9. JAVA中循环删除集合中元素的方法
  10. CENTOS7 Python3.7 PyAudio 安装
  11. 【递推】Ayoub and Lost Array
  12. Nginx反向代理 实现Web负载均衡
  13. 周记(2016-6-27 -- 2016-7-3)
  14. 印刷体汉字识别matlab实现,如何用MATLAB仿真印刷体汉字识别系统?
  15. 电子商务网站PPT选择服务器,第8章 电子商务系统规划与建设课件.ppt
  16. win10如何显示和隐藏文件夹
  17. chapter1 静态分析技术-09资源节查看 resource hacker
  18. STM32F103_study51_The punctual atoms(STM32 Timer interrupt )
  19. oracle的sid如何修改,Oracle数据库修改实例名SID的方法步骤
  20. 电子血压计方案PCBA控制板开发

热门文章

  1. C#发送企业内部邮件
  2. 【蓝桥杯嵌入式备赛】10.拓展板数码管、ADC按键及光敏电阻
  3. [转]叔本华《要么庸俗 要么孤独》
  4. 【2016NOIP普及组】T1:买铅笔 试题解析
  5. 快手+何向南团队最新论文Counterfactual Interactive Recommender System ,反事实推理融入离线强化学习,解决filter bubble/信息茧房问题
  6. 《剑来》语句摘录(三)
  7. SEO源码自建快排系统
  8. 恶搞版西游记,99%的人看完后当场含笑而死
  9. java笔试多么_世界多么精彩!
  10. calendar 5 android版,Calendars 5 by Readdle