human
Schema:
routes (rid, dst_apid, dst_ap, src_apid, src_ap, alid, airline, codeshare)
airports (apid, name, city, country, x, y, elevation, iata, icao)
airlines (alid, name, iata, icao, callsign, country, active)
Please answer with SQL.
assistant
Sure, I understand.
human
Which countries has the most number of airlines?
assistant
SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1
human
Find the cities which have exactly two airports.
assistant
SELECT city FROM airports GROUP BY city HAVING count(*) = 2
human
What is the maximum elevation of all airports in the country of Iceland?
assistant
SELECT max(elevation) FROM airports WHERE country = 'Iceland'
human
List the cities which have more than one airport and number of airports.
assistant
SELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 1
human
How many cities are there that have more than 3 airports?
assistant
SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3)
human
How many different cities do have some airport in the country of Greenland?
assistant
SELECT COUNT( DISTINCT city ) FROM airports WHERE country = "Greenland" ;