Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes for each source airport and the airport name. [/INST]

Output: SELECT count(*) ,  T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T1.name;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: For each airport name, how many routes start at that airport? [/INST]

Output: SELECT count(*) ,  T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T1.name;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes and airport name for each source airport, order the results by decreasing number of routes. [/INST]

Output: SELECT count(*) ,  T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: For each  airport name, how many routes start at that airport, ordered from most to least? [/INST]

Output: SELECT count(*) ,  T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T1.name ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the average elevation of all airports for each country. [/INST]

Output: SELECT avg(elevation) ,  country FROM airports GROUP BY country;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: For each country, what is the average elevation of that country's airports? [/INST]

Output: SELECT avg(elevation) ,  country FROM airports GROUP BY country;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the cities which have exactly two airports. [/INST]

Output: SELECT city FROM airports GROUP BY city HAVING count(*)  =  2;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the cities with exactly two airports? [/INST]

Output: SELECT city FROM airports GROUP BY city HAVING count(*)  =  2;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: For each country and airline name, how many routes are there? [/INST]

Output: SELECT T1.country ,  T1.name ,  count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T1.country ,  T1.name;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the total number of routes for each country and airline in that country? [/INST]

Output: SELECT T1.country ,  T1.name ,  count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T1.country ,  T1.name;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes with destination airports in Italy. [/INST]

Output: SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid  =  T2.apid WHERE T2.country  =  'Italy';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of routes whose destinations are Italian airports? [/INST]

Output: SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid  =  T2.apid WHERE T2.country  =  'Italy';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Return the number of routes with destination airport in Italy operated by the airline with name 'American Airlines'. [/INST]

Output: SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid  =  T2.apid JOIN airlines AS T3 ON T1.alid  =  T3.alid WHERE T2.country  =  'Italy' AND T3.name  =  'American Airlines';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of routes operated by the airline American Airlines whose destinations are in Italy? [/INST]

Output: SELECT count(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid  =  T2.apid JOIN airlines AS T3 ON T1.alid  =  T3.alid WHERE T2.country  =  'Italy' AND T3.name  =  'American Airlines';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes that have destination John F Kennedy International Airport. [/INST]

Output: SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE T1.name  =  'John F Kennedy International Airport';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of routes that end at John F Kennedy International Airport? [/INST]

Output: SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE T1.name  =  'John F Kennedy International Airport';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes from the United States to Canada. [/INST]

Output: SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country  =  'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country  =  'United States');


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many routes go from the United States to Canada? [/INST]

Output: SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country  =  'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country  =  'United States');


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the id of routes whose source and destination airports are in the United States. [/INST]

Output: SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country  =  'United States') AND src_apid IN (SELECT apid FROM airports WHERE country  =  'United States');


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the id of the routes whose source and destination airports are in the United States? [/INST]

Output: SELECT rid FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country  =  'United States') AND src_apid IN (SELECT apid FROM airports WHERE country  =  'United States');


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of airline which runs the most number of routes. [/INST]

Output: SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the airline with the most routes? [/INST]

Output: SELECT T1.name FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the busiest source airport that runs most number of routes in China. [/INST]

Output: SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid WHERE T1.country  =  'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the airport with the most number of routes that start in China? [/INST]

Output: SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid WHERE T1.country  =  'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the busiest destination airport that runs most number of routes in China. [/INST]

Output: SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE T1.country  =  'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the airport that is the destination of the most number of routes that start in China? [/INST]

Output: SELECT T1.name FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE T1.country  =  'China' GROUP BY T1.name ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What is the id of the most recent order? [/INST]

Output: SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the id of the order made most recently. [/INST]

Output: SELECT order_id FROM orders ORDER BY date_order_placed DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: what are the order id and customer id of the oldest order? [/INST]

Output: SELECT order_id ,  customer_id FROM orders ORDER BY date_order_placed LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the order id and customer id associated with the oldest order. [/INST]

Output: SELECT order_id ,  customer_id FROM orders ORDER BY date_order_placed LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the id of the order whose shipment tracking number is "3452". [/INST]

Output: SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which order's shipment tracking number is "3452"? Give me the id of the order. [/INST]

Output: SELECT order_id FROM shipments WHERE shipment_tracking_number = "3452";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the ids of all the order items whose product id is 11. [/INST]

Output: SELECT order_item_id FROM order_items WHERE product_id = 11;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find all the order items whose product id is 11. What are the order item ids? [/INST]

Output: SELECT order_item_id FROM order_items WHERE product_id = 11;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: List the name of all the distinct customers who have orders with status "Packing". [/INST]

Output: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customers have orders with status "Packing"? Give me the customer names. [/INST]

Output: SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Packing";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the details of all the distinct customers who have orders with status "On Road". [/INST]

Output: SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the distinct customers who have orders with status "On Road"? Give me the customer details? [/INST]

Output: SELECT DISTINCT T1.customer_details FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What is the name of the customer who has the most orders? [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customer made the most orders? Find the customer name. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What is the customer id of the customer who has the most orders? [/INST]

Output: SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the id of the customer who made the most orders. [/INST]

Output: SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Give me a list of id and status of orders which belong to the customer named "Jeramie". [/INST]

Output: SELECT T2.order_id ,  T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which orders are made by the customer named "Jeramie"? Give me the order ids and status. [/INST]

Output: SELECT T2.order_id ,  T2.order_status FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the dates of orders which belong to the customer named "Jeramie". [/INST]

Output: SELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the dates of the orders made by the customer named "Jeramie"? [/INST]

Output: SELECT T2.date_order_placed FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Give me the names of customers who have placed orders between 2009-01-01 and 2010-01-01. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customers made orders between 2009-01-01 and 2010-01-01? Find their names. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Give me a list of distinct product ids from orders placed between 1975-01-01 and 1976-01-01? [/INST]

Output: SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the distinct ids of products ordered between 1975-01-01 and 1976-01-01?? [/INST]

Output: SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the names of the customers who have order status both "On Road" and "Shipped". [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customers have both "On Road" and "Shipped" as order status? List the customer names. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the id of the customers who have order status both "On Road" and "Shipped". [/INST]

Output: SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which customers have both "On Road" and "Shipped" as order status? List the customer ids. [/INST]

Output: SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_id FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: When was the order placed whose shipment tracking number is 3452? Give me the date. [/INST]

Output: SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: On which day was the order placed whose shipment tracking number is 3452? [/INST]

Output: SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.shipment_tracking_number = 3452;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What is the placement date of the order whose invoice number is 10? [/INST]

Output: SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: On what day was the order with invoice number 10 placed? [/INST]

Output: SELECT T1.date_order_placed FROM orders AS T1 JOIN shipments AS T2 ON T1.order_id = T2.order_id WHERE T2.invoice_number = 10;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: List the count and id of each product in all the orders. [/INST]

Output: SELECT count(*) ,  T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: For each product, return its id and the number of times it was ordered. [/INST]

Output: SELECT count(*) ,  T3.product_id FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: List the name and count of each product in all orders. [/INST]

Output: SELECT T3.product_name ,  count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: For each product, show its name and the number of times it was ordered. [/INST]

Output: SELECT T3.product_name ,  count(*) FROM orders AS T1 JOIN order_items AS T2 JOIN products AS T3 ON T1.order_id = T2.order_id AND T2.product_id = T3.product_id GROUP BY T3.product_id;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the ids of orders which are shipped after 2000-01-01. [/INST]

Output: SELECT order_id FROM shipments WHERE shipment_date > "2000-01-01";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which orders have shipment after 2000-01-01? Give me the order ids. [/INST]

Output: SELECT order_id FROM shipments WHERE shipment_date > "2000-01-01";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the id of the order which is shipped most recently. [/INST]

Output: SELECT order_id FROM shipments WHERE shipment_date  =  (SELECT max(shipment_date) FROM shipments);


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which order has the most recent shipment? Give me the order id. [/INST]

Output: SELECT order_id FROM shipments WHERE shipment_date  =  (SELECT max(shipment_date) FROM shipments);


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

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

Output: SELECT DISTINCT product_name FROM products ORDER BY product_name;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Sort all the distinct products in alphabetical order. [/INST]

Output: SELECT DISTINCT product_name FROM products ORDER BY product_name;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: List the ids of all distinct orders ordered by placed date. [/INST]

Output: SELECT DISTINCT order_id FROM orders ORDER BY date_order_placed;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are ids of the all distinct orders, sorted by placement date? [/INST]

Output: SELECT DISTINCT order_id FROM orders ORDER BY date_order_placed;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What is the id of the order which has the most items? [/INST]

Output: SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Which order deals with the most items? Return the order id. [/INST]

Output: SELECT T1.order_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id GROUP BY T1.order_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What is the name of the customer who has the largest number of orders? [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the name of the customer who made the most orders. [/INST]

Output: SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY count(*) DESC LIMIT 1;


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the invoice numbers which are created before 1989-09-03 or after 2007-12-25. [/INST]

Output: SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the invoice numbers created before 1989-09-03 or after 2007-12-25? [/INST]

Output: SELECT invoice_number FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: Find the distinct details of invoices which are created before 1989-09-03 or after 2007-12-25. [/INST]

Output: SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: What are the distinct details of invoices created before 1989-09-03 or after 2007-12-25? [/INST]

Output: SELECT DISTINCT invoice_details FROM invoices WHERE invoice_date < "1989-09-03" OR invoice_date > "2007-12-25";


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

Invoices :
invoice_number [ INT ] primary_key
invoice_date [ TEXT ]
invoice_details [ TEXT ]

Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Orders.customer_id = Customers.customer_id
order_status [ TEXT ]
date_order_placed [ TEXT ]
order_details [ TEXT ]

Products :
product_id [ INT ] primary_key
product_name [ TEXT ]
product_details [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
product_id [ INT ] Order_Items.product_id = Products.product_id
order_id [ INT ] Order_Items.order_id = Orders.order_id
order_item_status [ TEXT ]
order_item_details [ TEXT ]

Shipments :
shipment_id [ INT ] primary_key
order_id [ INT ] Shipments.order_id = Orders.order_id
invoice_number [ INT ] Shipments.invoice_number = Invoices.invoice_number
shipment_tracking_number [ TEXT ]
shipment_date [ TEXT ]
other_shipment_details [ TEXT ]

Shipment_Items :
shipment_id [ INT ] Shipment_Items.shipment_id = Shipments.shipment_id
order_item_id [ INT ] Shipment_Items.order_item_id = Order_Items.order_item_id

Please write me a SQL statement that answers the following question: For each customer who has at least two orders, find the customer name and number of orders made. [/INST]

Output: SELECT T2.customer_name ,  count(*) FROM orders AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id HAVING count(*)  >=  2;