SELECT C.Name AS Country, SUM(T.Population) / C.Population AS
Relation
FROM Country C LEFT OUTER JOIN City T ON C.Code =T.CountryCode
WHERE C.Region = 'Nordic Countries'
GROUP BY C.Name
ORDER BY Relation DESC
LIMIT 1;
其他查询
SELECT C.Name AS Country, SUM(T.Population) / C.Population AS
Relation
FROM Country C LEFT OUTER JOIN City T ON C.Code =T.CountryCode
WHERE C.Region = 'Nordic Countries'
GROUP BY C.Name
ORDER BY Relation ASC
LIMIT 1;
1。这些使用城市和国家/地区表的查询,我无法在同一查询中获得最大关系和最小关系的情况下进行查询。