1、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')

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

select name from world
where continent='Europe' and
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 (select continent from world
where name in ('Argentina','Australia'))
order by name

4、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')

5、Show the name and the population of each country in Europe. Show the population as a percentage of the population of Germany.

select name,concat(round(population*100/(select population from world
where name='Germany')),'%') as percentage from world
where continent='Europe'

6、Which countries have a GDP greater than every country in Europe? [Give the name only.] (Some countries may have NULL gdp values)

select name from world
where gdp>all(select gdp from world
where continent='Europe'
and gdp>0)

7、Find the largest country (by area) in each continent, show the continent, the name and the area:

select continent,name,area from world x
where area>=all(select area from world y
where x.continent=y.continent
and area>0)

8、List each continent and the name of the country that comes first alphabetically.

select continent,name from world x
where name=(select min(name) from world y
where x.continent=y.continent)

9、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.

select name,continent,population from world
where continent not in (select continent from world
where population >25000000)

10、Some countries have populations more than three times that of all of their neighbours (in the same continent). Give the countries and continents.

select name,continent from world x
where population>3*(select max(population) from world y
where x.continent=y.continent and
x.population <> y.population)

https://sqlzoo.net/wiki/SELECT_within_SELECT_Tutorial

SQLZOO_SELECT within SELECT Tutorial(sql server)相关推荐

  1. How do I UPDATE from a SELECT in SQL Server?

    方法1 https://stackoverflow.com/questions/2334712/how-do-i-update-from-a-select-in-sql-server UPDATETa ...

  2. ssms2008 代码自动提示_使用 SSMS 的提示和技巧 - SQL Server Management Studio (SSMS) | Microsoft Docs...

    使用 SQL Server Management Studio (SSMS) 的提示和技巧Tips and tricks for using SQL Server Management Studio ...

  3. 使用SQL Server事务复制将SQL Server数据库迁移到Azure SQL数据库

    In this guide, we'll discuss more about migrating a SQL Server database to Azure SQL Database using ...

  4. SQL Server 2017的逐步安装

    介绍 (Introduction) The new SQL Server 2017 comes with new features in the installation. It now suppor ...

  5. SQL Server Management Studio –分步安装指南

    Why is this installation so important? Like any other technology, in SQL Server too we need to focus ...

  6. 比较和同步两个SQL Server数据库之间的图像

    介绍 (Introduction) Sometimes we lose data by mistake and we want to compare the data with older backu ...

  7. ssma迁移助手_如何使用SQL Server迁移助手(SSMA)和SSIS将MySQL表迁移到SQL Server

    ssma迁移助手 介绍 (Introduction) In this article, we will demonstrate how to migrate MySQL tables to SQL S ...

  8. 在SQL Server中如何获得刚插入一条新记录的自动ID号

    在SQL Server中如何获得刚插入一条新记录的自动ID号 收藏 --------------------------------------------------------------- 使用 ...

  9. SQL Server数据库中、获得刚插入新记录的自动ID号

    以下的文章主要是介绍在SQL Server数据库中正确获得刚插入一条新记录的自动ID号的实际操作过程,下面就是文章对其的主要内容的具体描述,望大家在浏览之后会对其有更深的了解. 使用[IDENT_CU ...

最新文章

  1. Linux下stat + 文件名后, Access,Modify,Change的含义
  2. 一文了解PL610-01-O96TC-R
  3. How do use my library
  4. 【Java并发编程】之八:多线程环境中安全使用集合API
  5. Linux查看内置命令和非内置命令帮助的几种方法(man、help、info)
  6. 最新!清华大学:元宇宙发展研究报告2.0版发布!205页PPT
  7. hadoop 自定义分区
  8. 深度学习笔记(9) 优化算法(一)
  9. python中linspace函数_numpy.linspace函数具体使用详解
  10. 智能快递柜10月1日起按新规管理
  11. [SHELL实例] (转)最牛B的 Linux Shell 命令 (一)
  12. datetime只要年月python_Python 的日期和时间处理
  13. pycharm用阿里云镜像_新购买的阿里云服务器准备到期时能否用学生身份优惠续费?...
  14. 计算机网络学习(四)网络层
  15. 计算机office demo,办公软件应用(Office2007)中级_DEMO盘-2013
  16. 计算机学不学p图的,五分钟学会P图!只需要电脑自带的看图软件!无需专业的PS软件!...
  17. ECS Windows服务器通过ie下载提示当前安全设置不允许下载该文件
  18. 优达学城 深度学习 任务3
  19. 阅读笔记-平凡的世界
  20. win7无法看到工作组计算机,Win7系统无法查看工作组问题的解决方法

热门文章

  1. 好心情:长期心情不好就是抑郁症?
  2. 【UE·GamePlay篇】攀爬系统系列教程(二)——相邻墙壁飞跃、墙角拐弯、回头反向跳
  3. java类中获取tomcat下的webap路径方法
  4. 刘强东在耶鲁北京中心演讲(2015-8):商城+金融+3农+生鲜
  5. asp功放怎么装_功放音响安装—教您如何安装功放音响
  6. php adodb smarty,ADODB结合SMARTY使用~超级强
  7. IOC容器中bean的生命周期,iocbean生命周期
  8. Ophir Vega激光功率计
  9. 算法竞赛-ch2-水仙花数
  10. 【中文题库】CISCO CCNP题库 642-892(P3.23)中文解释