sql - Include a record only if it has more than 20 related records -


this statement i'm using:

select     country.code "country code",     country.name country,         count(countrycode) "number of cities"     city,     country     city.countrycode = country.code group country.code, country.name; 

i need select countries have more 20 cities. create view query afterwards.

use having clause aggregate functions:

... group country.code, country.name having count(countrycode) > 20; 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -