2019-06-13 MySQL嵌套查询语句

MySQL嵌套查询语句统计每个省的人口最多的与最少的城市

SELECT District,NAME,Population FROM city WHERE Population IN (SELECT MIN(Population) FROM city 
WHERE city.CountryCode='CHN'
GROUP BY city.District)
UNION
SELECT District,NAME,Population FROM city WHERE Population IN (SELECT MAX(Population) FROM city 
WHERE city.CountryCode='CHN'
GROUP BY city.District)

你可能感兴趣的:(2019-06-13 MySQL嵌套查询语句)