db_name
stringclasses
146 values
prompt
stringlengths
310
4.81k
activity_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Activity ( actid, activity_name ) # Participates_in ( stuid, actid ) # Faculty_Participates_in ( FacID, actid ) # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # # Participates_in.actid can be joined with Activity.actid # Participates_in.stuid can be joined with Student.StuID # Faculty_Participates_in.actid can be joined with Activity.actid # Faculty_Participates_in.FacID can be joined with Faculty.FacID # ### Question: # # What are the first names of the faculty members playing both Canoeing and Kayaking? # ### SQL: # # SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' INTERSECT SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Kayaking' # ### End.
activity_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Activity ( actid, activity_name ) # Participates_in ( stuid, actid ) # Faculty_Participates_in ( FacID, actid ) # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # # Participates_in.actid can be joined with Activity.actid # Participates_in.stuid can be joined with Student.StuID # Faculty_Participates_in.actid can be joined with Activity.actid # Faculty_Participates_in.FacID can be joined with Faculty.FacID # ### Question: # # Find the ids of the students who participate in Canoeing and Kayaking. # ### SQL: # # SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Kayaking' # ### End.
activity_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Activity ( actid, activity_name ) # Participates_in ( stuid, actid ) # Faculty_Participates_in ( FacID, actid ) # Student ( StuID, LName, Fname, Age, Sex, Major, Advisor, city_code ) # Faculty ( FacID, Lname, Fname, Rank, Sex, Phone, Room, Building ) # # Participates_in.actid can be joined with Activity.actid # Participates_in.stuid can be joined with Student.StuID # Faculty_Participates_in.actid can be joined with Activity.actid # Faculty_Participates_in.FacID can be joined with Faculty.FacID # ### Question: # # Which students participate in both Canoeing and Kayaking as their activities? Tell me their student ids. # ### SQL: # # SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid = T2.actid WHERE T2.activity_name = 'Kayaking' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the name of the airport in the city of Goroka. # ### SQL: # # SELECT name FROM airports WHERE city = 'Goroka' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the names of the airports in the city of Goroka? # ### SQL: # # SELECT name FROM airports WHERE city = 'Goroka' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the name, city, country, and altitude (or elevation) of the airports in the city of New York. # ### SQL: # # SELECT name , city , country , elevation FROM airports WHERE city = 'New York' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name, city, country, and elevation for every airport in the city of New York? # ### SQL: # # SELECT name , city , country , elevation FROM airports WHERE city = 'New York' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many airlines are there? # ### SQL: # # SELECT count(*) FROM airlines # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the total number of airlines? # ### SQL: # # SELECT count(*) FROM airlines # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many airlines does Russia has? # ### SQL: # # SELECT count(*) FROM airlines WHERE country = 'Russia' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of airlines based in Russia? # ### SQL: # # SELECT count(*) FROM airlines WHERE country = 'Russia' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the maximum elevation of all airports in the country of Iceland? # ### SQL: # # SELECT max(elevation) FROM airports WHERE country = 'Iceland' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the highest elevation of an airport in the country of Iceland? # ### SQL: # # SELECT max(elevation) FROM airports WHERE country = 'Iceland' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the name of the airports located in Cuba or Argentina. # ### SQL: # # SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the names of all airports in Cuba or Argentina? # ### SQL: # # SELECT name FROM airports WHERE country = 'Cuba' OR country = 'Argentina' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the country of the airlines whose name starts with 'Orbit'. # ### SQL: # # SELECT country FROM airlines WHERE name LIKE 'Orbit%' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the countries of all airlines whose names start with Orbit? # ### SQL: # # SELECT country FROM airlines WHERE name LIKE 'Orbit%' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the name of airports whose altitude is between -50 and 50. # ### SQL: # # SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the names of all airports whose elevation is between -50 and 50? # ### SQL: # # SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Which country is the airport that has the highest altitude located in? # ### SQL: # # SELECT country FROM airports ORDER BY elevation DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the country of the airport with the highest elevation? # ### SQL: # # SELECT country FROM airports ORDER BY elevation DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the number of airports whose name contain the word 'International'. # ### SQL: # # SELECT count(*) FROM airports WHERE name LIKE '%International%' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many airports' names have the word Interanation in them? # ### SQL: # # SELECT count(*) FROM airports WHERE name LIKE '%International%' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many different cities do have some airport in the country of Greenland? # ### SQL: # # SELECT count(DISTINCT city) FROM airports WHERE country = 'Greenland' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # In how many cities are there airports in the country of Greenland? # ### SQL: # # SELECT count(DISTINCT city) FROM airports WHERE country = 'Greenland' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many routes does American Airlines operate? # ### SQL: # # SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many routes end in a Canadian airport? # ### SQL: # # SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE country = 'Canada' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name, city, and country of the airport with the lowest altitude? # ### SQL: # # SELECT name , city , country FROM airports ORDER BY elevation LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name, city, and country of the airport with the highest elevation? # ### SQL: # # SELECT name , city , country FROM airports ORDER BY elevation DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 , T2.dst_apid 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name and city of the airport that the most routes end at? # ### SQL: # # SELECT T1.name , T1.city , T2.dst_apid 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the names of the top 10 airlines that operate the most number of routes. # ### SQL: # # SELECT T1.name , T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # For the airline ids with the top 10 most routes operated, what are their names? # ### SQL: # # SELECT T1.name , T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 , T2.src_apid 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name and city of the airport from most of the routes start? # ### SQL: # # SELECT T1.name , T1.city , T2.src_apid 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of different different airports that are destinations for 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' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Which countries has the most number of airlines? # ### SQL: # # SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name of the country with the most number of home airlines? # ### SQL: # # SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the countries with the most airlines whose active status is Y? # ### SQL: # # SELECT country FROM airlines WHERE active = 'Y' GROUP BY country ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many airlines operate out of each country in descending order? # ### SQL: # # SELECT country , count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of airports per country, ordered from most to least? # ### SQL: # # SELECT count(*) , country FROM airports GROUP BY country ORDER BY count(*) DESC # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many airports are there per city in the United States? Order the cities by decreasing number of airports. # ### SQL: # # SELECT count(*) , city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY count(*) DESC # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many airports are there per city in the US ordered from most to least? # ### SQL: # # SELECT count(*) , city FROM airports WHERE country = 'United States' GROUP BY city ORDER BY count(*) DESC # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Return the cities with more than 3 airports in the United States. # ### SQL: # # SELECT city FROM airports WHERE country = 'United States' GROUP BY city HAVING count(*) > 3 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of cities in the United States with more than 3 airports? # ### SQL: # # SELECT city FROM airports WHERE country = 'United States' GROUP BY city HAVING count(*) > 3 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many cities are there that have more than 3 airports? # ### SQL: # # SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3) # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the count of cities with more than 3 airports? # ### SQL: # # SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*) > 3) # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # List the cities which have more than one airport and number of airports. # ### SQL: # # SELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the names of all cities with more than one airport and how many airports do they have? # ### SQL: # # SELECT city , count(*) FROM airports GROUP BY city HAVING count(*) > 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # List the cities which have more than 2 airports sorted by the number of airports. # ### SQL: # # SELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*) # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the cities that have more than 2 airports sorted by number of airports? # ### SQL: # # SELECT city FROM airports GROUP BY city HAVING count(*) > 2 ORDER BY count(*) # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the number of routes for each source airport and the airport name. # ### SQL: # # SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # For each airport name, how many routes start at that airport? # ### SQL: # # SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the number of routes and airport name for each source airport, order the results by decreasing number of routes. # ### SQL: # # SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # For each airport name, how many routes start at that airport, ordered from most to least? # ### SQL: # # SELECT count(*) , T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the average elevation of all airports for each country. # ### SQL: # # SELECT avg(elevation) , country FROM airports GROUP BY country # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # For each country, what is the average elevation of that country's airports? # ### SQL: # # SELECT avg(elevation) , country FROM airports GROUP BY country # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the cities which have exactly two airports. # ### SQL: # # SELECT city FROM airports GROUP BY city HAVING count(*) = 2 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What are the cities with exactly two airports? # ### SQL: # # SELECT city FROM airports GROUP BY city HAVING count(*) = 2 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # For each country and airline name, how many routes are there? # ### SQL: # # 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the total number of routes for each country and airline in that country? # ### SQL: # # 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 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the number of routes with destination airports in Italy. # ### SQL: # # SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of routes whose destinations are Italian airports? # ### SQL: # # SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'. # ### SQL: # # SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of routes operated by the airline American Airlines whose destinations are in Italy? # ### SQL: # # SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid JOIN airlines AS T3 ON T1.alid = T3.alid WHERE T2.country = 'Italy' AND T3.name = 'American Airlines' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the number of routes that have destination John F Kennedy International Airport. # ### SQL: # # SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the number of routes that end at John F Kennedy International Airport? # ### SQL: # # SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.name = 'John F Kennedy International Airport' # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the number of routes from the United States to Canada. # ### SQL: # # SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States') # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # How many routes go from the United States to Canada? # ### SQL: # # SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States') # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the id of routes whose source and destination airports are in the United States. # ### SQL: # # SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States') # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the id of the routes whose source and destination airports are in the United States? # ### SQL: # # SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'United States') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States') # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the name of airline which runs the most number of routes. # ### SQL: # # SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name of the airline with the most routes? # ### SQL: # # SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the busiest source airport that runs most number of routes in China. # ### SQL: # # SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name of the airport with the most number of routes that start in China? # ### SQL: # # SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # Find the busiest destination airport that runs most number of routes in China. # ### SQL: # # SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
flight_4
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # # routes.alid can be joined with airlines.alid # routes.src_apid can be joined with airports.apid # routes.dst_apid can be joined with airports.apid # ### Question: # # What is the name of the airport that is the destination of the most number of routes that start in China? # ### SQL: # # SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.dst_apid WHERE T1.country = 'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # What is the id of the most recent order? # ### SQL: # # SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Find the id of the order made most recently. # ### SQL: # # SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # what are the order id and customer id of the oldest order? # ### SQL: # # SELECT order_id , customer_id FROM orders ORDER BY date_order_placed LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Find the order id and customer id associated with the oldest order. # ### SQL: # # SELECT order_id , customer_id FROM orders ORDER BY date_order_placed LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Find the id of the order whose shipment tracking number is "3452". # ### SQL: # # SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452" # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Which order's shipment tracking number is "3452"? Give me the id of the order. # ### SQL: # # SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452" # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Find the ids of all the order items whose product id is 11. # ### SQL: # # SELECT order_item_id FROM order_items WHERE product_id = 11 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Find all the order items whose product id is 11. What are the order item ids? # ### SQL: # # SELECT order_item_id FROM order_items WHERE product_id = 11 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # List the name of all the distinct customers who have orders with status "Packing". # ### SQL: # # SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing" # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Which customers have orders with status "Packing"? Give me the customer names. # ### SQL: # # SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing" # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Find the details of all the distinct customers who have orders with status "On Road". # ### SQL: # # SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # What are the distinct customers who have orders with status "On Road"? Give me the customer details? # ### SQL: # # SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # What is the name of the customer who has the most orders? # ### SQL: # # SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # Which customer made the most orders? Find the customer name. # ### SQL: # # SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1 # ### End.
tracking_orders
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Customers ( customer_id, customer_name, customer_details ) # Invoices ( invoice_number, invoice_date, invoice_details ) # Orders ( order_id, customer_id, order_status, date_order_placed, order_details ) # Products ( product_id, product_name, product_details ) # Order_Items ( order_item_id, product_id, order_id, order_item_status, order_item_details ) # Shipments ( shipment_id, order_id, invoice_number, shipment_tracking_number, shipment_date, other_shipment_details ) # Shipment_Items ( shipment_id, order_item_id ) # # Orders.customer_id can be joined with Customers.customer_id # Order_Items.product_id can be joined with Products.product_id # Order_Items.order_id can be joined with Orders.order_id # Shipments.invoice_number can be joined with Invoices.invoice_number # Shipments.order_id can be joined with Orders.order_id # Shipment_Items.shipment_id can be joined with Shipments.shipment_id # Shipment_Items.order_item_id can be joined with Order_Items.order_item_id # ### Question: # # What is the customer id of the customer who has the most orders? # ### SQL: # # SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1 # ### End.