Database: flight_4

Question: Find the name of the airports located in Cuba or Argentina.
SQL: SELECT name FROM airports WHERE country  =  'Cuba' OR country  =  'Argentina'

Question: Find the country of the airlines whose name starts with 'Orbit'.
SQL: SELECT country FROM airlines WHERE name LIKE 'Orbit%'

Question: Which country is the airport that has the highest altitude located in?
SQL: SELECT country FROM airports ORDER BY elevation DESC LIMIT 1

Question: Find the number of airports whose name contain the word 'International'.
SQL: SELECT count(*) FROM airports WHERE name LIKE '%International%'

Question: Find the number of routes operated by American Airlines.
SQL: SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid WHERE T1.name  =  'American Airlines'

Question: Find the number of routes whose destination airports are in Canada.
SQL: SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE country  =  'Canada'

Question: Find the name, city, and country of the airport that has the lowest altitude.
SQL: SELECT name ,  city ,  country FROM airports ORDER BY elevation LIMIT 1

Question: Find the name, city, and country of the airport that has the highest latitude.
SQL: SELECT name ,  city ,  country FROM airports ORDER BY elevation DESC LIMIT 1

Question: Find the name and city of the airport which is the destination of the most number of routes.
SQL: SELECT T1.name,  T1.city FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid GROUP BY T2.dst_apid ORDER BY count(*) DESC LIMIT 1

Question: Find the names of the top 10 airlines that operate the most number of routes.
SQL: SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10

Question: Find the name and city of the airport which is the source for the most number of flight routes.
SQL: SELECT T1.name, T1.city FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T2.src_apid ORDER BY count(*) DESC LIMIT 1

Question: Find the number of different airports which are the destinations of the American Airlines.
SQL: SELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid WHERE T1.name  =  'American Airlines'

Question: Which countries has the most number of airlines?
SQL: SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1

Question: Which countries has the most number of airlines whose active status is 'Y'?
SQL: SELECT country FROM airlines WHERE active  =  'Y' GROUP BY country ORDER BY count(*) DESC LIMIT 1

Question: List all countries and their number of airlines in the descending order of number of airlines.
SQL: SELECT country ,  count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC

Question: How many airports are there per country? Order the countries by decreasing number of airports.
SQL: SELECT count(*) ,  country FROM airports GROUP BY country ORDER BY count(*) DESC