codernikhilgoyal145
codernikhilgoyal145

Reputation: 11

How to write the SQL QUERY for this question

Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

Upvotes: 1

Views: 660

Answers (1)

zealous
zealous

Reputation: 7503

Try the following

select 
   c.continent,
   floor(avg(ci.population))
from country c
join city ci
on c.Code = ci.countrycode 
group by 
   c.continent;

Upvotes: 1

Related Questions