CREATE TABLE airlines (
    uid NUMBER PRIMARY KEY,
    Airline TEXT,
    Abbreviation TEXT,
    Country TEXT
);
CREATE TABLE airports (
    City TEXT,
    AirportCode TEXT PRIMARY KEY,
    AirportName TEXT,
    Country TEXT,
    CountryAbbrev TEXT
);
CREATE TABLE flights (
    Airline NUMBER PRIMARY KEY,
    FlightNo NUMBER,
    SourceAirport TEXT,
    DestAirport TEXT,
    FOREIGN KEY ("DestAirport") REFERENCES airports("AirportCode"),
    FOREIGN KEY ("SourceAirport") REFERENCES airports("AirportCode")
);

Question: What is the code of airport that has the highest number of flights?
SQL: SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode  =  T2.DestAirport OR T1.AirportCode  =  T2.SourceAirport GROUP BY T1.AirportCode ORDER BY count(*) DESC LIMIT 1

Question: What is the airport code of the airport with the most flights?
SQL: SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode  =  T2.DestAirport OR T1.AirportCode  =  T2.SourceAirport GROUP BY T1.AirportCode ORDER BY count(*) DESC LIMIT 1

Question: What is the code of airport that has fewest number of flights?
SQL: SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode  =  T2.DestAirport OR T1.AirportCode  =  T2.SourceAirport GROUP BY T1.AirportCode ORDER BY count(*) LIMIT 1

Question: Give the code of the airport with the least flights.
SQL: SELECT T1.AirportCode FROM AIRPORTS AS T1 JOIN FLIGHTS AS T2 ON T1.AirportCode  =  T2.DestAirport OR T1.AirportCode  =  T2.SourceAirport GROUP BY T1.AirportCode ORDER BY count(*) LIMIT 1

Question: Which airline has most number of flights?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline ORDER BY count(*) DESC LIMIT 1

Question: What airline serves the most flights?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline ORDER BY count(*) DESC LIMIT 1

Question: Find the abbreviation and country of the airline that has fewest number of flights?
SQL: SELECT T1.Abbreviation ,  T1.Country FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline ORDER BY count(*) LIMIT 1

Question: What is the abbreviation of the airilne has the fewest flights and what country is it in?
SQL: SELECT T1.Abbreviation ,  T1.Country FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline ORDER BY count(*) LIMIT 1

Question: What are airlines that have some flight departing from airport 'AHD'?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "AHD"

Question: Which airlines have a flight with source airport AHD?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "AHD"

Question: What are airlines that have flights arriving at airport 'AHD'?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.DestAirport  =  "AHD"

Question: Which airlines have a flight with destination airport AHD?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.DestAirport  =  "AHD"

Question: Find all airlines that have flights from both airports 'APG' and 'CVO'.
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "APG" INTERSECT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "CVO"

Question: Which airlines have departing flights from both APG and CVO airports?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "APG" INTERSECT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "CVO"

Question: Find all airlines that have flights from airport 'CVO' but not from 'APG'.
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "CVO" EXCEPT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "APG"

Question: Which airlines have departures from CVO but not from APG airports?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "CVO" EXCEPT SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline WHERE T2.SourceAirport  =  "APG"

Question: Find all airlines that have at least 10 flights.
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline HAVING count(*)  >  10

Question: Which airlines have at least 10 flights?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline HAVING count(*)  >  10

Question: Find all airlines that have fewer than 200 flights.
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline HAVING count(*)  <  200

Question: Which airlines have less than 200 flights?
SQL: SELECT T1.Airline FROM AIRLINES AS T1 JOIN FLIGHTS AS T2 ON T1.uid  =  T2.Airline GROUP BY T1.Airline HAVING count(*)  <  200

Question: What are flight numbers of Airline "United Airlines"?
SQL: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRLINES AS T2 ON T2.uid  =  T1.Airline WHERE T2.Airline  =  "United Airlines"

Question: Which flight numbers correspond to United Airlines flights?
SQL: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRLINES AS T2 ON T2.uid  =  T1.Airline WHERE T2.Airline  =  "United Airlines"

Question: What are flight numbers of flights departing from Airport "APG"?
SQL: SELECT FlightNo FROM FLIGHTS WHERE SourceAirport  =  "APG"

Question: Give the flight numbers of flights leaving from APG.
SQL: SELECT FlightNo FROM FLIGHTS WHERE SourceAirport  =  "APG"

Question: What are flight numbers of flights arriving at Airport "APG"?
SQL: SELECT FlightNo FROM FLIGHTS WHERE DestAirport  =  "APG"

Question: Give the flight numbers of flights landing at APG.
SQL: SELECT FlightNo FROM FLIGHTS WHERE DestAirport  =  "APG"

Question: What are flight numbers of flights departing from City "Aberdeen "?
SQL: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport   =  T2.AirportCode WHERE T2.City  =  "Aberdeen"

Question: Give the flight numbers of flights leaving from Aberdeen.
SQL: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport   =  T2.AirportCode WHERE T2.City  =  "Aberdeen"

Question: What are flight numbers of flights arriving at City "Aberdeen"?
SQL: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport   =  T2.AirportCode WHERE T2.City  =  "Aberdeen"

Question: Give the flight numbers of flights arriving in Aberdeen.
SQL: SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.DestAirport   =  T2.AirportCode WHERE T2.City  =  "Aberdeen"

Question: Find the number of flights landing in the city of Aberdeen or Abilene.
SQL: SELECT count(*) FROM Flights AS T1 JOIN Airports AS T2 ON T1.DestAirport  =  T2.AirportCode WHERE T2.city  =  "Aberdeen" OR T2.city  =  "Abilene"

Question: How many flights land in Aberdeen or Abilene?
SQL: SELECT count(*) FROM Flights AS T1 JOIN Airports AS T2 ON T1.DestAirport  =  T2.AirportCode WHERE T2.city  =  "Aberdeen" OR T2.city  =  "Abilene"

Question: Find the name of airports which do not have any flight in and out.
SQL: SELECT AirportName FROM Airports WHERE AirportCode NOT IN (SELECT SourceAirport FROM Flights UNION SELECT DestAirport FROM Flights)

Question: Which airports do not have departing or arriving flights?
SQL: SELECT AirportName FROM Airports WHERE AirportCode NOT IN (SELECT SourceAirport FROM Flights UNION SELECT DestAirport FROM Flights)