I have a database called world
.
(我有一个名为world
的数据库。)
This database has two tables: city
and country
. (该数据库有两个表: city
和country
。)
city
's columns are: name
, ID
, Population
, countryCode
.
(city
的countryCode
: name
, ID
, Population
, countryCode
。)
country
's columns are: Code
, name
, countryPopulation
, Capital
.
(country
的列是: Code
, name
, countryPopulation
, Capital
。)
Write a query that displays the names of cities and their countries when the capital city is the largest of all cities listed for that country.
(编写一个查询,以显示首都及其所在国家中所有城市中最大的城市的名称。)
Here is the code that displays the largest cities list:
(这是显示最大城市列表的代码:)
SELECT MAX(c.Population) AS Population, c.Name AS City, cou.Name AS Country
FROM city c, country cou
WHERE c.CountryCode = cou.Code
GROUP BY cou.Name
Suppose I have that information from previous code:
(假设我有以前代码中的信息:)
Population City Country
1000000 Washington DC USA
993943210 Sao Paulo Brazil
1911919 Dubai UAE
My query should show all cities in the USA because Washington DC is the capital of USA and all cities in the UAE because Dubai is the capital of UAE but should not show cities in Brazil because Sao Paulo is not the capital of Brazil.
(我的查询应显示美国的所有城市,因为华盛顿特区是美国的首都,而阿联酋的所有城市,因为迪拜是阿联酋的首都,但不应该显示巴西的城市,因为圣保罗不是巴西的首都。)
ask by Tiger07 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…