sqlzoo:2
顯示具有至少2億人口的國家名稱。 2億是200000000,有八個零。
SELECT name FROM world
WHERE population>=200000000
找出有至少200百萬(2億)人口的國家名稱,及人均國內生產總值。
select name ,GDP/population
from world
where population >=200000000
顯示'South America'南美洲大陸的國家名字和以百萬為單位人口數。 將人口population 除以一百萬(1000000)得可得到以百萬為單位人口數。
select name,population/1000000
from world
where continent like 'South America'
顯示法國,德國,意大利(France, Germany, Italy)的國家名稱和人口。
select name,population
from world
where name in('France','Germany','Italy')
顯示包含單詞“United”為名稱的國家。
select name
from world
where name like '%United%'
成為大國的兩種方式:如果它有3百萬平方公里以上的面積,或擁有250百萬(2.5億)以上人口。
select name,population,area
from world
where area>3000000 or population>250000000
美國、印度和中國(USA, India, China)是人口又大,同時面積又大的國家。排除這些國家。顯示以人口或面積為大國的國家,但不能同時兩者。顯示國家名稱,人口和面積。
select name,population,area
from world
where (area>3000000 and population<250000000) or
(area<3000000 and population>250000000)
除以为1000000(6个零)是以百万计。除以十亿(9个零)是以十亿计。使用ROUND函数来显示的数值到小数点后两位。
select name,round(population/1000000,2),round(gdp/1000000000,2)
from world
where continent='South America'
顯示國家有至少一個萬億元國內生產總值(萬億,也就是12個零)的人均國內生產總值。四捨五入這個值到最接近1000。
select name,round(gdp/population,-3)
from world
where gdp>=1000000000000
Show the name - but substitute Australasia for Oceania - for countries beginning with N.
SELECT name,
CASE WHEN continent='Oceania' THEN 'Australasia'
ELSE continent END
FROM world
WHERE name LIKE 'N%'
Show the name and the continent - but substitute Eurasia for Europe and Asia; substitute America - for each country in North America or South America or Caribbean. Show countries beginning with A or B
SELECT name,
CASE WHEN continent IN('Europe','Asia')
THEN 'Eurasia'
WHEN continent IN('North America','South America','Caribbean')
THEN 'America'
ELSE continent END
FROM world
WHERE name LIKE 'A%' OR name LIKE 'B%'
Put the continents right...
- Oceania becomes Australasia
- Countries in Eurasia and Turkey go to Europe/Asia
- Caribbean islands starting with 'B' go to North America, other Caribbean islands go to South America
select name,continent,
case when continent in ('Eurasia', 'Turkey')
then 'Europe/Asia'
when continent = 'Oceania'
then 'Australasia'
when continent = 'Caribbean'
then
case
when name LIKE 'B%'
then 'North America'
else 'South America'
end
else continent end
from world
order by name asc
sqlzoo:2的更多相关文章
- 练习sql语句的好去处——http://www.sqlzoo.cn/
sql语句的编写需要按照实际的例子来练习. 如果自己来做准备,需要你自己搭好数据库,建好库和表,还要填入数据,最后自己想出题目和正确答案. 不过,现在我发现了一个好去处,http://www.sqlz ...
- sqlzoo练习题答案
title: SQL-Learning date: 2019-03-12 20:37:21 tags: SQL --- 这是关于在一个SQL学习网站的练习题答案记录:SQL教程 SQL基础 由一些简单 ...
- sqlzoo易错题
https://sqlzoo.net/wiki/SELECT_names 答案在:https://github.com/codyloyd/sqlzoo-solutions/blob/master/SQ ...
- SQLZOO 习题
https://sqlzoo.net 8. 美國.印度和中國(USA, India, China)是人口又大,同時面積又大的國家.排除這些國家. 顯示以人口或面積為大國的國家,但不能同時兩者.顯示國家 ...
- More JOIN operations -- SQLZOO
The JOIN operation 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.List the films where the y ...
- The JOIN operation -- SQLZOO
The JOIN operation 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.Modify it to show the matc ...
- SUM and COUNT -- SQLZOO
SUM and COUNT 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.Show the total population of th ...
- SELECT within SELECT Tutorial -- SQLZOO
SELECT within SELECT Tutorial 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.List each count ...
- sqlzoo - SELECT from WORLD Tutorial 答案
01.SELECT from WORLD Tutorial 01.显示所有国家的名称,大洲和人口. SELECT name, continent, population FROM world; 02. ...
- sqlzoo.net刷题5
List the continents that have a total population of at least 100 million. 这题考察的是使用集聚函数生成表之后,如何过滤 一般我 ...
随机推荐
- VMware Workstation 常见问题解决
本文以FAQ的方式进行整理,大家可以根据关键字进行查找即可. 问题一:VMware 安装64位操作系统报错“此主机支持Intel VT-x, 但Intel VT-x处于禁用状态” 问题二:This v ...
- 【opencv实践】边缘检测
边缘检测: 一.canny算子 Canny边缘检测根据对信噪比与定位乘积进行测度,得到最优化逼近算子,也就是Canny算子.类似与 LoG 边缘检测方法,也属于先平滑后求导数的方法. 二.canny算 ...
- springboot-文件上传xls及POI操作Excel
1.pom导入依赖文件 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-o ...
- 红警大战JAVA简单版
代码结构: 相关源码: 武器类: 属性:武器,攻击力,子弹数量. 方法:给属性赋值(set属性()方法) 获取属性值(get属性()方法) package 红警大战简单版; public class ...
- Selenium+PhantomJS替代方案
问题描述: python3在使用selenium+PhantomJS动态抓取网页时,出现如下报错信息: UserWarning: Selenium support for PhantomJS has ...
- Python爬虫从入门到进阶(2)之urllib库的使用
1.什么是Urllib(官网地址:https://docs.python.org/3/library/urllib.html#module-urllib) Urllib是python内置的HTTP请求 ...
- IntelliJ Idea 第一次使用
概括 程序员每次电脑重新安装或者新的电脑上进行开发时都会安装一些开发软件,这时候基本都是去官网下载,然后破解(中国程序员啊哈哈)进行快乐使用,为了让自己方便小编也写一个,不用去别人那里找来找去 安装I ...
- nodejs分离html文件里面的js和css
摘要: 本文要实现的内容,使用nodejs 对文件的增删改查,演示的例子->分离出一个html 文件里面的script 和style 里面的内容,然后单独生成js文件和css 文件.中间处理异步 ...
- 写一个python脚本监控在linux中的进程
在虚拟机中安装Linux中的CentOS7系统 https://baijiahao.baidu.com/s?id=1597320700700593557&wfr=spider&for= ...
- 中小学Python编程语言教学
中小学Python编程语言教学 作为一名高中信息技术老师,被技术的发展潮流推动着,不断更新教学内容和方法,以适应快速发展的信息社会. 以前的中小学信息技术课程,老师们各显神通,身怀绝技,教PS,Fal ...