SELECT within SELECT Tutorial -- SQLZOO
SELECT within SELECT Tutorial

注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道
01.List each country name where the population is larger than that of 'Russia'.
译文:列出每个国家的人口超过“俄罗斯”的名字。
select name from world where population>(select population from world where name='Russia' )
02.Show the countries in Europe with a per capita GDP greater than 'United Kingdom'.
译文:显示欧洲国家的人均GDP大于“英国”。
select name from world where continent='Europe' and (GDP/POPULATION)>(select gdp/population from world where name='United Kingdom')
03.List the name and continent of countries in the continents containing either Argentina or Australia. Order by name of the country.
译文:列出包括阿根廷或澳大利亚在内的各大洲的国家名称和大洲。按国家名称排序。
select name,continent from world where continent in (select continent from world where name in('Argentina', 'Australia')) order by name
04.Which country has a population that is more than Canada but less than Poland? Show the name and the population.
译文:哪个国家的人口比加拿大多但比波兰少?显示名字和人口。
select name,population from world where population>(select population from world where name='Canada ') and population<(select population from world where name='Poland')
05.Show the name and the population of each country in Europe. Show the population as a percentage of the population of Germany.
译文:显示欧洲每个国家的名称和人口。显示人口占德国人口的百分比。
# 这题写的有点问题 concat拼接的时候自己在%加上了好多零
SELECT name,concat(round(population/(select population from world where name='Germany'),2)* 100, '%')
FROM world
WHERE continent='Europe'
06.Which countries have a GDP greater than every country in Europe? [Give the name only.] (Some countries may have NULL gdp values)
译文:哪些国家的GDP比欧洲的每个国家都高?只告诉我名字。(有些国家可能有零gdp值)
select name from world where GDP > (select max(GDP) from world where continent='Europe')
07.Find the largest country (by area) in each continent, show the continent, the name and the area:
译文:在每个洲找出最大的国家(按面积),显示洲,名称和地区:
select continent,name,area from world where area in(select max(area) from world group by continent)
08.List each continent and the name of the country that comes first alphabetically.
译文:按字母顺序列出每个洲和国家名称。
SELECT continent,name FROM world a WHERE name <= ALL(SELECT name from world b WHERE a.continent = b.continent )ORDER by name
09.Find the continents where all countries have a population <= 25000000. Then find the names of the countries associated with these continents. Show name, continent and population.
译文:找出所有国家的人口都小于2500亿的大陆。然后找出与这些大陆相关的国家的名字。显示姓名,大陆和人口。
SELECT name,continent,population FROM world x WHERE 25000000 >= ALL(SELECT population FROM world y WHERE y.continent = x.continent)
10.Some countries have populations more than three times that of any of their neighbours (in the same continent). Give the countries and continents.
译文:有些国家的人口是其邻国(在同一大陆)的三倍还多。给出国家和大陆。
SELECT name,continent FROM world x WHERE x.population/3 >= ALL(SELECT population FROM world y WHERE y.continent = x.continent AND y.name != x.name)
练习网址:https://sqlzoo.net/wiki/SELECT_within_SELECT_Tutorial
------------------------------------------------------------------------------------------------------------------------------------------------------------------

SELECT within SELECT Tutorial -- SQLZOO的更多相关文章
- sqlzoo - SELECT from WORLD Tutorial 答案
01.SELECT from WORLD Tutorial 01.显示所有国家的名称,大洲和人口. SELECT name, continent, population FROM world; 02. ...
- sqlzoo刷题 SELECT from Nobel Tutorial
SELECT from Nobel Tutorial 1.Change the query shown so that it displays Nobel prizes for 1950. SELEC ...
- SELECT from Nobel Tutorial
02.SELECT from Nobel Tutorial 注意:where语句中对表示条件的需要用单引号, 下面的译文使用的是有道翻译如有不正确,请直接投诉有道 01.Change the quer ...
- SQL笔记1:SELECT及SELECT高级应用
T-SQL笔记1:SELECT及SELECT高级应用 本章摘要 1:安装AdventureWorks 2:基本运算符和表达式 3:between 4:like 5:escape 6:TOP 7:G ...
- PHP MySQL Select 之Select
从数据库表中选取数据 SELECT 语句用于从数据库中选取数据. 语法 SELECT column_name(s) FROM table_name 注释:SQL 语句对大小写不敏感.SELECT 与 ...
- select * from (select P.*,ROWNUM RN FROM(select * from Mp_Relatedart where pubbaseid=785 order by ID ASC )P)M WHERE M.RN>2 and M.RN <= 7
select * from (select P.*,ROWNUM RN FROM(select * from Mp_Relatedart where pubbaseid=785 order by ID ...
- sql: sybase与oracle中insert into select和select into的用法
1. sybase与oracle中insert into select和select into的用法 http://wjlvivid.iteye.com/blog/1921679 Sybase 一.首 ...
- 关于Select * 与Select 字段名 的问题!
[转]http://blog.csdn.net/tongyu2009/article/details/8252418 1.SELECT * 语句取出表中的所有字段,不论该字段的数据对调用的应用程序是否 ...
- select * 和 select 所有字段的区别
阅读本文大概需要 1 分钟. 之前发过的文章中,关于 select * 和 select 所有字段的知识,有描述不恰当,这次重新纠正下,加深下理解. MySQL 5.1.37 表记录数 41,547, ...
随机推荐
- Oracle IO性能测试
Oracle IO性能测试 前言 最近发生了迁移测试库后(单节点迁移RAC)因为IO性能问题导致迁移后性能非常差的问题. 原本想在创建ASM磁盘组之前用Orion做测试,但是忘了做就没做结果出了这档子 ...
- Python3笔记015 - 3.6 空语句
第3章 流程控制语句 3.6 空语句 # pass 占位符,暂时不做任何事情,方便后面补充功能 for i in range(1,10): if i%2 == 0: print(i, end = '' ...
- 优化:在k8s上部署的gitlab
gitlab组件图 gitlab在k8s上占用资源 # kubectl top pods -n default | grep git* gitlab-gitaly-0 9m 444Mi gitlab- ...
- 【板子】数论基础(持续更新ing...)
#include<cstdio> #include<iostream> #include<cstring> #include<cmath> #inclu ...
- C# 跨平台UI 技术
构建跨平台应用程序的的几种UI技术,以C# 或者其他基于.NET的 语言(诸如:Visual Basic[VB]).本文研究了三种跨平台技术,并讨论了在哪些情况下开发人员可以使用这些技术.本文使你对可 ...
- PE文件格式详解(七)
PE文件格式详解(七) Ox00 前言 前面好几篇在讲输入表,今天要讲的是输出表和地址的是地址重定位.有了前面的基础,其实对于怎么找输出表地址重定位的表已经非常熟悉了. 0x01 输出表结构 ...
- Django之实现登录随机验证码
登录验证码是每个网站登录时的基本标配,网上也有很多相应的文章, 但是从生成验证码到 应用到自己的网站上的全步骤,并没有看到很多, 为了节约大家的时间,我把整体步骤写下来, 即拿即用哈 1. 生成随机验 ...
- Django适当进阶篇
本节内容 学员管理系统练习 Django ORM操作进阶 用户认证 Django练习小项目:学员管理系统设计开发 带着项目需求学习是最有趣和效率最高的,今天就来基于下面的需求来继续学习Django 项 ...
- Python并发编程05 /死锁现象、递归锁、信号量、GIL锁、计算密集型/IO密集型效率验证、进程池/线程池
Python并发编程05 /死锁现象.递归锁.信号量.GIL锁.计算密集型/IO密集型效率验证.进程池/线程池 目录 Python并发编程05 /死锁现象.递归锁.信号量.GIL锁.计算密集型/IO密 ...
- 一、Python系列——函数的应用之名片管理系统
card_list = [] def main_desk(): print('*'*50) print('欢迎使用[名片管理系统]V1.0') print('1.新建名片') print('2.显示全 ...