SQL ZOO 练习 —— SELECT within SELECT Tutorial

本文通过一系列SQL查询示例,详细解析如何在查询中使用子查询来执行更复杂的数据库操作,包括筛选人口超过俄罗斯的国家、找出欧洲人均GDP高于英国的国家、按面积查找各大洲的最大国家等。这些例子涵盖了从基础的子查询到高级的ALL和IN关键字的用法,是提升SQL技能的好资料。

This tutorial looks at how we can use SELECT statements within SELECT statements to perform more complex queries.
在这里插入图片描述

1.List each country name where the population is larger than that of ‘Russia’.

world(name, continent, area, population, gdp)

SELECT name FROM world
  WHERE population >
     (SELECT population FROM world
      WHERE name='Russia')

2.Show the countries in Europe with a per capita GDP greater than ‘United Kingdom’.

SELECT name FROM world
WHERE continent = 'Europe' AND name IN
   (SELECT name FROM world 
    WHERE gdp/population > 
            (SELECT gdp/population FROM world WHERE name = 'United Kingdom' ) )

3.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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值