Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: what is the name of every pilot who is at least 25 years old? [/INST]

Output: SELECT Name FROM pilot WHERE Age  >=  25;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List all pilot names in ascending alphabetical order. [/INST]

Output: SELECT Name FROM pilot ORDER BY Name ASC;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of the pilots in alphabetical order? [/INST]

Output: SELECT Name FROM pilot ORDER BY Name ASC;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List names of all pilot aged 30 or younger in descending alphabetical order. [/INST]

Output: SELECT Name FROM pilot WHERE Age  <=  30 ORDER BY Name DESC;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of all pilots 30 years old or young in descending alphabetical order? [/INST]

Output: SELECT Name FROM pilot WHERE Age  <=  30 ORDER BY Name DESC;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: Please show the names of aircrafts associated with airport with name "London Gatwick". [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Airport_Name  =  "London Gatwick";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of all the aircrafts associated with London Gatwick airport? [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Airport_Name  =  "London Gatwick";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: Please show the names and descriptions of aircrafts associated with airports that have a total number of passengers bigger than 10000000. [/INST]

Output: SELECT T1.Aircraft ,  T1.Description FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Total_Passengers  >  10000000;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names and descriptions of aircrafts associated with an airport that has more total passengers than 10000000? [/INST]

Output: SELECT T1.Aircraft ,  T1.Description FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Total_Passengers  >  10000000;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the average total number of passengers of airports that are associated with aircraft "Robinson R-22"? [/INST]

Output: SELECT avg(T3.Total_Passengers) FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T1.Aircraft  =  "Robinson R-22";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the average total number of passengers for all airports that the aircraft "Robinson R-22" visits? [/INST]

Output: SELECT avg(T3.Total_Passengers) FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T1.Aircraft  =  "Robinson R-22";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: Please list the location and the winning aircraft name. [/INST]

Output: SELECT T2.Location ,  T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the location and name of the winning aircraft? [/INST]

Output: SELECT T2.Location ,  T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List the name of the aircraft that has been named winning aircraft the most number of times. [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the name of the aircraft that has won an award the most? [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List the names of aircrafts and the number of times it won matches. [/INST]

Output: SELECT T1.Aircraft ,  COUNT(*) FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: For each aircraft that has won an award, what is its name and how many time has it won? [/INST]

Output: SELECT T1.Aircraft ,  COUNT(*) FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List names of all pilot in descending order of age. [/INST]

Output: SELECT Name FROM pilot ORDER BY Age DESC;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of all pilots listed by descending age? [/INST]

Output: SELECT Name FROM pilot ORDER BY Age DESC;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List the names of aircrafts and that won matches at least twice. [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft HAVING COUNT(*)  >=  2;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of all aircrafts that have won a match at least twice? [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN MATCH AS T2 ON T1.Aircraft_ID  =  T2.Winning_Aircraft GROUP BY T2.Winning_Aircraft HAVING COUNT(*)  >=  2;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: List the names of aircrafts and that did not win any match. [/INST]

Output: SELECT Aircraft FROM aircraft WHERE Aircraft_ID NOT IN (SELECT Winning_Aircraft FROM MATCH);


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of all aicrafts that have never won any match? [/INST]

Output: SELECT Aircraft FROM aircraft WHERE Aircraft_ID NOT IN (SELECT Winning_Aircraft FROM MATCH);


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: Show the names of aircrafts that are associated with both an airport named "London Heathrow" and an airport named "London Gatwick" [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Airport_Name  =  "London Heathrow" INTERSECT SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Airport_Name  =  "London Gatwick";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of all aircrafts that are associated with both London Heathrow and Gatwick airports? [/INST]

Output: SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Airport_Name  =  "London Heathrow" INTERSECT SELECT T1.Aircraft FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.Aircraft_ID  =  T2.Aircraft_ID JOIN airport AS T3 ON T2.Airport_ID  =  T3.Airport_ID WHERE T3.Airport_Name  =  "London Gatwick";


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: Show all information on the airport that has the largest number of international passengers. [/INST]

Output: SELECT * FROM airport ORDER BY International_Passengers DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is all the information on the airport with the largest number of international passengers? [/INST]

Output: SELECT * FROM airport ORDER BY International_Passengers DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: find the name and age of the pilot who has won the most number of times among the pilots who are younger than 30. [/INST]

Output: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot WHERE t1.age  <  30 GROUP BY t2.winning_pilot ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What is the name and age of the pilot younger than 30 who has won the most number of times? [/INST]

Output: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot WHERE t1.age  <  30 GROUP BY t2.winning_pilot ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: what is the name and age of the youngest winning pilot? [/INST]

Output: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot ORDER BY t1.age LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: How old is the youngest winning pilot and what is their name? [/INST]

Output: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot ORDER BY t1.age LIMIT 1;


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: find the name of pilots who did not win the matches held in the country of Australia. [/INST]

Output: SELECT name FROM pilot WHERE pilot_id NOT IN (SELECT Winning_Pilot  FROM MATCH WHERE country  =  'Australia');


Input:
[INST] Here is a database schema:
pilot :
Pilot_Id [ INT ] primary_key
Name [ TEXT ]
Age [ INT ]

aircraft :
Aircraft_ID [ INT ] primary_key
Aircraft [ TEXT ]
Description [ TEXT ]
Max_Gross_Weight [ TEXT ]
Total_disk_area [ TEXT ]
Max_disk_Loading [ TEXT ]

match :
Round [ INT ] primary_key
Location [ TEXT ]
Country [ TEXT ]
Date [ TEXT ]
Fastest_Qualifying [ TEXT ]
Winning_Pilot [ TEXT ] match.Winning_Pilot = pilot.Pilot_Id
Winning_Aircraft [ TEXT ] match.Winning_Aircraft = aircraft.Aircraft_ID

airport :
Airport_ID [ INT ] primary_key
Airport_Name [ TEXT ]
Total_Passengers [ INT ]
%_Change_2007 [ TEXT ]
International_Passengers [ INT ]
Domestic_Passengers [ INT ]
Transit_Passengers [ INT ]
Aircraft_Movements [ INT ]
Freight_Metric_Tonnes [ INT ]

airport_aircraft :
ID [ INT ]
Airport_ID [ INT ] primary_key airport_aircraft.Airport_ID = airport.Airport_ID
Aircraft_ID [ INT ] airport_aircraft.Aircraft_ID = aircraft.Aircraft_ID

Please write me a SQL statement that answers the following question: What are the names of the pilots that have not won any matches in Australia? [/INST]

Output: SELECT name FROM pilot WHERE pilot_id NOT IN (SELECT Winning_Pilot  FROM MATCH WHERE country  =  'Australia');


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: How many residents does each property have? List property id and resident count. [/INST]

Output: SELECT T1.property_id ,  count(*) FROM properties AS T1 JOIN residents AS T2 ON T1.property_id  =  T2.property_id GROUP BY T1.property_id;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What is the distinct service types that are provided by the organization which has detail 'Denesik and Sons Party'? [/INST]

Output: SELECT DISTINCT T1.service_type_code FROM services AS T1 JOIN organizations AS T2 ON T1.organization_id  =  T2.organization_id WHERE T2.organization_details  =  'Denesik and Sons Party';


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: How many services has each resident requested? List the resident id, details, and the count in descending order of the count. [/INST]

Output: SELECT T1.resident_id ,  T1.other_details ,  count(*) FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id  =  T2.resident_id GROUP BY T1.resident_id ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What is the maximum number that a certain service is provided? List the service id, details and number. [/INST]

Output: SELECT T1.service_id ,  T1.service_details ,  count(*) FROM Services AS T1 JOIN Residents_Services AS T2 ON T1.service_id  =  T2.service_id GROUP BY T1.service_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: List the id and type of each thing, and the details of the organization that owns it. [/INST]

Output: SELECT T1.thing_id ,  T1.type_of_Thing_Code ,  T2.organization_details FROM Things AS T1 JOIN Organizations AS T2 ON T1.organization_id  =  T2.organization_id;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What are the id and details of the customers who have at least 3 events? [/INST]

Output: SELECT T1.customer_id ,  T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id HAVING count(*)  >=  3;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What is each customer's move in date, and the corresponding customer id and details? [/INST]

Output: SELECT T2.date_moved_in ,  T1.customer_id ,  T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id  =  T2.customer_id;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: Which events have the number of notes between one and three? List the event id and the property id. [/INST]

Output: SELECT T1.Customer_Event_ID  ,  T1.property_id FROM Customer_Events AS T1 JOIN Customer_Event_Notes AS T2 ON T1.Customer_Event_ID  =  T2.Customer_Event_ID GROUP BY T1.customer_event_id HAVING count(*) BETWEEN 1 AND 3;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct id and type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21' [/INST]

Output: SELECT DISTINCT T2.thing_id ,  T2.Type_of_Thing_Code FROM Timed_Status_of_Things AS T1 JOIN Things AS T2 ON T1.thing_id  =  T2.thing_id WHERE T1.Status_of_Thing_Code  =  'Close' OR T1.Date_and_Date  <  '2017-06-19 02:59:21';


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: How many distinct locations have the things with service detail 'Unsatisfied' been located in? [/INST]

Output: SELECT count(DISTINCT T2.Location_Code) FROM Things AS T1 JOIN Timed_Locations_of_Things AS T2 ON T1.thing_id  =  T2.thing_id WHERE T1.service_details  =  'Unsatisfied';


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: How many different status codes of things are there? [/INST]

Output: SELECT count(DISTINCT Status_of_Thing_Code) FROM Timed_Status_of_Things;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: Which organizations are not a parent organization of others? List the organization id. [/INST]

Output: SELECT organization_id FROM organizations EXCEPT SELECT parent_organization_id FROM organizations;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: When is the last day any resident moved in? [/INST]

Output: SELECT max(date_moved_in) FROM Residents;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What are the resident details containing the substring 'Miss'? [/INST]

Output: SELECT other_details FROM Residents WHERE other_details LIKE '%Miss%';


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: List the customer event id and the corresponding move in date and property id. [/INST]

Output: SELECT customer_event_id ,  date_moved_in ,  property_id FROM customer_events;


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: How many customers did not have any event? [/INST]

Output: SELECT count(*) FROM customers WHERE customer_id NOT IN ( SELECT customer_id FROM customer_events );


Input:
[INST] Here is a database schema:
Customers :
customer_id [ INT ] primary_key
customer_details [ TEXT ]

Properties :
property_id [ INT ] primary_key
property_type_code [ TEXT ]
property_address [ TEXT ]
other_details [ TEXT ]

Residents :
resident_id [ INT ] primary_key
property_id [ INT ] Residents.property_id = Properties.property_id
date_moved_in [ TEXT ]
date_moved_out [ TEXT ]
other_details [ TEXT ]

Organizations :
organization_id [ INT ] primary_key
parent_organization_id [ INT ]
organization_details [ TEXT ]

Services :
service_id [ INT ] primary_key
organization_id [ INT ] Services.organization_id = Organizations.organization_id
service_type_code [ TEXT ]
service_details [ TEXT ]

Residents_Services :
resident_id [ INT ] primary_key Residents_Services.resident_id = Residents.resident_id
service_id [ INT ] Residents_Services.service_id = Services.service_id
date_moved_in [ TEXT ] Residents_Services.date_moved_in = Residents.date_moved_in
property_id [ INT ] Residents_Services.property_id = Residents.property_id
date_requested [ TEXT ]
date_provided [ TEXT ]
other_details [ TEXT ]

Things :
thing_id [ INT ] primary_key
organization_id [ INT ] Things.organization_id = Organizations.organization_id
Type_of_Thing_Code [ TEXT ]
service_type_code [ TEXT ]
service_details [ TEXT ]

Customer_Events :
Customer_Event_ID [ INT ] primary_key
customer_id [ INT ] Customer_Events.customer_id = Customers.customer_id
date_moved_in [ TEXT ] Customer_Events.date_moved_in = Residents.date_moved_in
property_id [ INT ] Customer_Events.property_id = Residents.property_id
resident_id [ INT ] Customer_Events.resident_id = Residents.resident_id
thing_id [ INT ] Customer_Events.thing_id = Things.thing_id

Customer_Event_Notes :
Customer_Event_Note_ID [ INT ] primary_key
Customer_Event_ID [ INT ] Customer_Event_Notes.Customer_Event_ID = Customer_Events.Customer_Event_ID
service_type_code [ TEXT ]
resident_id [ INT ]
property_id [ INT ]
date_moved_in [ TEXT ]

Timed_Status_of_Things :
thing_id [ INT ] primary_key Timed_Status_of_Things.thing_id = Things.thing_id
Date_and_Date [ TEXT ]
Status_of_Thing_Code [ TEXT ]

Timed_Locations_of_Things :
thing_id [ INT ] primary_key Timed_Locations_of_Things.thing_id = Things.thing_id
Date_and_Time [ TEXT ]
Location_Code [ TEXT ]

Please write me a SQL statement that answers the following question: What are the distinct move in dates of the residents? [/INST]

Output: SELECT DISTINCT date_moved_in FROM residents;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: How many schools are there? [/INST]

Output: SELECT count(*) FROM school;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: Count the number of schools. [/INST]

Output: SELECT count(*) FROM school;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: List the locations of schools in ascending order of enrollment. [/INST]

Output: SELECT LOCATION FROM school ORDER BY Enrollment ASC;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: What is the list of school locations sorted in ascending order of school enrollment? [/INST]

Output: SELECT LOCATION FROM school ORDER BY Enrollment ASC;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: List the locations of schools in descending order of founded year. [/INST]

Output: SELECT LOCATION FROM school ORDER BY Founded DESC;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: What is the list of school locations sorted in descending order of school foundation year? [/INST]

Output: SELECT LOCATION FROM school ORDER BY Founded DESC;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: What are the enrollments of schools whose denomination is not "Catholic"? [/INST]

Output: SELECT Enrollment FROM school WHERE Denomination != "Catholic";


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: List the enrollment for each school that does not have "Catholic" as denomination. [/INST]

Output: SELECT Enrollment FROM school WHERE Denomination != "Catholic";


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: What is the average enrollment of schools? [/INST]

Output: SELECT avg(Enrollment) FROM school;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: Take the average of the school enrollment. [/INST]

Output: SELECT avg(Enrollment) FROM school;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: What are the teams of the players, sorted in ascending alphabetical order? [/INST]

Output: SELECT Team FROM player ORDER BY Team ASC;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: Find the team of each player and sort them in ascending alphabetical order. [/INST]

Output: SELECT Team FROM player ORDER BY Team ASC;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: How many different positions of players are there? [/INST]

Output: SELECT count(DISTINCT POSITION) FROM player;


Input:
[INST] Here is a database schema:
school :
School_ID [ INT ] primary_key
School [ TEXT ]
Location [ TEXT ]
Enrollment [ INT ]
Founded [ INT ]
Denomination [ TEXT ]
Boys_or_Girls [ TEXT ]
Day_or_Boarding [ TEXT ]
Year_Entered_Competition [ INT ]
School_Colors [ TEXT ]

school_details :
School_ID [ INT ] primary_key school_details.School_ID = school.School_ID
Nickname [ TEXT ]
Colors [ TEXT ]
League [ TEXT ]
Class [ TEXT ]
Division [ TEXT ]

school_performance :
School_Id [ INT ] primary_key school_performance.School_Id = school.School_ID
School_Year [ TEXT ]
Class_A [ TEXT ]
Class_AA [ TEXT ]

player :
Player_ID [ INT ] primary_key
Player [ TEXT ]
Team [ TEXT ]
Age [ INT ]
Position [ TEXT ]
School_ID [ INT ] player.School_ID = school.School_ID

Please write me a SQL statement that answers the following question: Count the number of distinct player positions. [/INST]

Output: SELECT count(DISTINCT POSITION) FROM player;