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
For each country and airline name, how many routes are there?
assistant
SELECT T1.country , T1.name , count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.country , T1.name
human
Find the number of routes operated by American Airlines.
assistant
SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines'
human
How many airlines are there?
assistant
SELECT count(*) FROM airlines
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
What is the number of different different airports that are destinations for American Airlines?
assistant
SELECT COUNT( DISTINCT dst_apid ) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = "American Airlines" ;