Database: flight_1

Question: Show flight number for all flights with more than 2000 distance.
SQL: SELECT flno FROM Flight WHERE distance  >  2000

Question: What is the average price for flights from Los Angeles to Honolulu.
SQL: SELECT avg(price) FROM Flight WHERE origin  =  "Los Angeles" AND destination  =  "Honolulu"

Question: Show origin and destination for flights with price higher than 300.
SQL: SELECT origin ,  destination FROM Flight WHERE price  >  300

Question: Show the flight number and distance of the flight with maximum price.
SQL: SELECT flno ,  distance FROM Flight ORDER BY price DESC LIMIT 1

Question: Show the flight number of flights with three lowest distances.
SQL: SELECT flno FROM Flight ORDER BY distance ASC LIMIT 3

Question: What is the average distance and average price for flights from Los Angeles.
SQL: SELECT avg(distance) ,  avg(price) FROM Flight WHERE origin  =  "Los Angeles"

Question: Show all origins and the number of flights from each origin.
SQL: SELECT origin ,  count(*) FROM Flight GROUP BY origin

Question: Show all destinations and the number of flights to each destination.
SQL: SELECT destination ,  count(*) FROM Flight GROUP BY destination

Question: Which origin has most number of flights?
SQL: SELECT origin FROM Flight GROUP BY origin ORDER BY count(*) DESC LIMIT 1

Question: Which destination has least number of flights?
SQL: SELECT destination FROM Flight GROUP BY destination ORDER BY count(*) LIMIT 1

Question: What is the aircraft name for the flight with number 99
SQL: SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid  =  T2.aid WHERE T1.flno  =  99

Question: Show all flight numbers with aircraft Airbus A340-300.
SQL: SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid  =  T2.aid WHERE T2.name  =  "Airbus A340-300"

Question: Show aircraft names and number of flights for each aircraft.
SQL: SELECT T2.name ,  count(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid  =  T2.aid GROUP BY T1.aid

Question: Show names for all aircraft with at least two flights.
SQL: SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid  =  T2.aid GROUP BY T1.aid HAVING count(*)  >= 2

Question: How many employees have certificate.
SQL: SELECT count(DISTINCT eid) FROM Certificate

Question: Show ids for all employees who do not have a certificate.
SQL: SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate

Question: Show names for all aircrafts of which John Williams has certificates.
SQL: SELECT T3.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid  =  T2.eid JOIN Aircraft AS T3 ON T3.aid  =  T2.aid WHERE T1.name  =  "John Williams"

Question: Show names for all employees who have certificate of Boeing 737-800.
SQL: SELECT T1.name FROM Employee AS T1 JOIN Certificate AS T2 ON T1.eid  =  T2.eid JOIN Aircraft AS T3 ON T3.aid  =  T2.aid WHERE T3.name  =  "Boeing 737-800"