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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -