这是我使用的声明:
SELECT
country.code as "Country Code",
country.name as Country,
count(countrycode) as "Number Of Cities"
FROM
city,
country
WHERE
city.countrycode = country.code
GROUP BY country.code, country.name;
我需要选择拥有超过20个城市的国家/地区。之后我将为此查询创建一个视图。
答案 0 :(得分:3)
对聚合函数使用HAVING
子句:
...
GROUP BY country.code, country.name
HAVING COUNT(countrycode) > 20;