sqlzoo转

http://m.blog.csdn.net/article/details?id=50504578

SELECT within SELECT Tutorial

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 gdp > 0 and continent=‘Europe‘)

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

SELECT continent, name, area FROM world x
WHERE x.area >=
ALL(SELECT y.area FROM world y
WHERE y.continent=x.continent
AND area>0)
select continent,name,area from world where area in(SELECT max(area) FROM world group by continent)

8.List each continent and the name of the country that comes first alphabetically.分组后,每组数据中的第一行

select continent,name
from world as x
where x.name=(
select y.name from world as y where y.continent=x.continent order by name limit 1)

9.Find the continents where all countries have a population <= 25000000. Then find the names of the countries associated with these continents. Show namecontinent and population.

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

  

时间: 2024-10-13 22:55:53

sqlzoo转的相关文章

sqlzoo练习答案--The JOIN operation

game id mdate stadium team1 team2 1001 8 June 2012 National Stadium, Warsaw POL GRE 1002 8 June 2012 Stadion Miejski (Wroclaw) RUS CZE 1003 12 June 2012 Stadion Miejski (Wroclaw) GRE CZE 1004 12 June 2012 National Stadium, Warsaw POL RUS ... goal mat

sqlzoo练习答案--SELECT within SELECT Tutorial

This tutorial looks at how we can use SELECT statements within SELECT statements to perform more complex queries. name continent area population gdp Afghanistan Asia 652230 25500100 20343000000 Albania Europe 28748 2831741 12960000000 Algeria Africa

sqlzoo.net刷题5

List the continents that have a total population of at least 100 million. select continent from world group by continent having sum(population)>=100000000 这题考察的是使用集聚函数生成表之后,如何过滤 一般我们生成一个查询结果集都会使用 where 表达式来过滤不想要的内容, 但是group by分组表达式在SQL中是在where过滤之后才能执

sqlzoo.net刷题4

SELECT name, continent FROM world a WHERE population > (SELECT MAX(population) * 3 FROM world b WHERE a.continent = b.continent AND a.name <> b.name) http://dba.stackexchange.com/questions/4066/cant-retrieve-data-of-countries-and-regions 老外也有在论坛为

sqlzoo.net刷题3

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. 这道题,我一开始理解错了,我以为是整个洲人口 <= 25000000,然后列出这些洲所在的国家以及人口 后来select几遍之后才发现理解错题

sqlzoo练习答案--SUM and COUNT

World Country Profile: Aggregate functions This tutorial is about aggregate functions such as COUNT, SUM and AVG. An aggregate function takes many values and delivers just one value. For example the function SUM would aggregate the values 2, 4 and 5

sqlzoo练习答案--More JOIN operations

Movie Database This tutorial introduces the notion of a join. The database consists of three tables movie , actor and casting . movie actor casting id id movieid title name actorid yr   ord director     budget     gross           1.List the films whe

sqlzoo.net刷题2

Find the largest country (by area) in each continent, show the continent, thename and the area: 找到每个洲面积最大的国家: SELECT continent, name, area FROM world x WHERE area >= ALL (SELECT area FROM world y WHERE y.continent=x.continent AND area>0) 其实这种>=AL

sqlzoo练习答案--SELECT from Nobel Tutorial/zh

nobel 諾貝爾獎得獎者 我們繼續練習簡單的單一表格SQL查詢. 這個教程是有關諾貝爾獎得獎者的: nobel(yr, subject, winner) yr subject winner 1960 Chemistry Willard F. Libby 1960 Literature Saint-John Perse 1960 Medicine Sir Frank Macfarlane Burnet 1960 Medicine Peter Madawar ... yr: 年份subject: