input
stringlengths 358
16.1k
| output
stringlengths 24
805
|
---|---|
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: What are the destinations of the flights with air carrier description "Southeast Alaska Airlines: WEB"? [/INST] | SELECT T2.DEST FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Southeast Alaska Airlines: WEB'; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: From August 10 to August 20, 2018, how many cancelled flights of air carrier named Spirit Air Lines: NK are there? [/INST] | SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Spirit Air Lines: NK' AND T2.CANCELLED = 0 AND T2.FL_DATE BETWEEN '2018/8/10' AND '2018/8/20'; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the total number of flights that flew on August 2, 2018 with air carrier described as Horizon Air? [/INST] | SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%Horizon Air%' AND T2.FL_DATE = '2018/8/2'; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: What is the tail number of the flight with air carrier named Iscargo Hf: ICQ and arrival time of 1000 and below? [/INST] | SELECT T2.TAIL_NUM FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ARR_TIME <= 1000 AND T1.Description = 'Iscargo Hf: ICQ'; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: List the flight date of flights with air carrier described as Profit Airlines Inc.: XBH which have an actual elapsed time below 100. [/INST] | SELECT T2.FL_DATE FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ACTUAL_ELAPSED_TIME < 100 AND T1.Description = 'Profit Airlines Inc.: XBH'; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the flights with air carrier named Republic Airline, how many of the flights have departure delay of 30 minutes and above? [/INST] | SELECT COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%Republic Airline%' AND T2.DEP_DELAY > 30; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: What are the air carriers of the flights that flew on August 25, 2018 that have departure delay of -5? [/INST] | SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.FL_DATE = '2018/8/25' GROUP BY T1.Description; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: Provide the air carrier description of the flight with a tail number N922US from Phoenix. [/INST] | SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T2.Code = T1.OP_CARRIER_AIRLINE_ID WHERE T1.TAIL_NUM = 'N922US' AND T1.ORIGIN = 'PHX' GROUP BY T2.Description; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: Give the air carrier description of the flights that have an earlier arrival and departure. [/INST] | SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.ARR_DELAY < 0 AND T2.DEP_DELAY < 0 GROUP BY T1.Description; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the flights with air carrier "Southwest Airlines Co.: WN", provide the tail number of flights with an actual elapsed time lower than the 80% of the average actual elapsed time of listed flights. [/INST] | SELECT T2.TAIL_NUM FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description = 'Southwest Airlines Co.: WN' AND T2.ACTUAL_ELAPSED_TIME < ( SELECT AVG(ACTUAL_ELAPSED_TIME) * 0.8 FROM Airlines ); |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: List the air carrier's description with arrival time lower than the 40% of the average arrival time of flights that flew to Phoenix. [/INST] | SELECT T1.Description FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T2.DEST = 'PHX' AND T2.ARR_TIME < ( SELECT AVG(ARR_TIME) * 0.4 FROM Airlines ) GROUP BY T1.Description; |
[INST] Here is a database schema:
Air Carriers :
Code [ INTEGER ] primary_key
Description [ TEXT ]
Airports :
Code [ TEXT ] primary_key
Description [ TEXT ]
Airlines :
FL_DATE [ TEXT ]
OP_CARRIER_AIRLINE_ID [ INTEGER ] Airlines.OP_CARRIER_AIRLINE_ID = Air Carriers.Code
TAIL_NUM [ TEXT ]
OP_CARRIER_FL_NUM [ INTEGER ]
ORIGIN_AIRPORT_ID [ INTEGER ]
ORIGIN_AIRPORT_SEQ_ID [ INTEGER ]
ORIGIN_CITY_MARKET_ID [ INTEGER ]
ORIGIN [ TEXT ] Airlines.ORIGIN = Airports.Code
DEST_AIRPORT_ID [ INTEGER ]
DEST_AIRPORT_SEQ_ID [ INTEGER ]
DEST_CITY_MARKET_ID [ INTEGER ]
DEST [ TEXT ] Airlines.DEST = Airports.Code
CRS_DEP_TIME [ INTEGER ]
DEP_TIME [ INTEGER ]
DEP_DELAY [ INTEGER ]
DEP_DELAY_NEW [ INTEGER ]
ARR_TIME [ INTEGER ]
ARR_DELAY [ INTEGER ]
ARR_DELAY_NEW [ INTEGER ]
CANCELLED [ INTEGER ]
CANCELLATION_CODE [ TEXT ]
CRS_ELAPSED_TIME [ INTEGER ]
ACTUAL_ELAPSED_TIME [ INTEGER ]
CARRIER_DELAY [ INTEGER ]
WEATHER_DELAY [ INTEGER ]
NAS_DELAY [ INTEGER ]
SECURITY_DELAY [ INTEGER ]
LATE_AIRCRAFT_DELAY [ INTEGER ]
Please write me a SQL statement that answers the following question: Among the flights of the air carrier described as American Airlines, what is the percentage of the flights with earlier departure? [/INST] | SELECT CAST(SUM(CASE WHEN T2.DEP_DELAY < 0 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM `Air Carriers` AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.OP_CARRIER_AIRLINE_ID WHERE T1.Description LIKE '%American Airlines%'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among the books published by publisher ID 1929, how many of them have over 500 pages? [/INST] | SELECT COUNT(*) FROM book WHERE publisher_id = 1929 AND num_pages > 500; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the publication date of the book with the most pages? [/INST] | SELECT publication_date FROM book ORDER BY num_pages DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the publisher of the book "The Illuminati"? [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Illuminati'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books were published by publisher "Thomas Nelson"? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the publisher that has published the most number of books? [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T1.book_id) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Please give the title of the oldest book published by publisher "Thomas Nelson". [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' ORDER BY T1.publication_date ASC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among the books published by publisher "Thomas Nelson", how many of them have over 300 pages? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' AND T1.num_pages > 300; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the publisher of the book with the most pages? [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id ORDER BY T1.num_pages DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books are in English? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'English'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Please list the titles of all the books in British English. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'British English'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the cheapest order price of the book "The Little House"? [/INST] | SELECT MIN(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'The Little House'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Please list the titles of all the books that Lucas Wyldbore has ordered. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Lucas' AND T4.last_name = 'Wyldbore'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among the books ordered by Lucas Wyldbore, how many of them are over 300 pages? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Lucas' AND T4.last_name = 'Wyldbore' AND T1.num_pages > 300; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the total price of all the books ordered by Lucas Wyldbore? [/INST] | SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How much money on average does Lucas Wyldbore spend on book orders? [/INST] | SELECT SUM(T1.price) / COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among the books ordered by Lucas Wyldbore, what is the percentage of those books over $13? [/INST] | SELECT CAST(SUM(CASE WHEN T1.price > 13 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which city does the address id 547 belong to? [/INST] | SELECT city FROM address WHERE address_id = 547; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many orders has Cordy Dumbarton made? [/INST] | SELECT COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id WHERE T1.first_name = 'Cordy' AND T1.last_name = 'Dumbarton'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List the title of the earliest published Japanese book. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'Japanese' ORDER BY T1.publication_date ASC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: For the publisher which published the most books, show its name. [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T2.publisher_id) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books were published by Kensington? [/INST] | SELECT COUNT(T1.book_id) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Kensington'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which language was book id 1405 written in? [/INST] | SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.book_id = 1405; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which customer has made the most orders? Show his/her full name. [/INST] | SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(*) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Name the book title of the bestseller. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id GROUP BY T1.title ORDER BY COUNT(T1.title) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books did David Foster Wallace write? [/INST] | SELECT COUNT(T1.title) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'David Foster Wallace'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many orders does the book "O Xará" have? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'O Xará'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which country does Malina Johnson live in? [/INST] | SELECT T4.country_name FROM customer AS T1 INNER JOIN customer_address AS T2 ON T1.customer_id = T2.customer_id INNER JOIN address AS T3 ON T3.address_id = T2.address_id INNER JOIN country AS T4 ON T4.country_id = T3.country_id WHERE T1.first_name = 'Malina' AND T1.last_name = 'Johnson' AND T2.status_id = 2; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Give the number of Ukrainian addresses in the database. [/INST] | SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T1.country_name = 'Ukraine'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which country does Žirovnica city belong to? [/INST] | SELECT T1.country_name FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T2.city = 'Žirovnica'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Calculate the percentage of the International shipping orders on 2022/11/10. [/INST] | SELECT CAST(SUM(CASE WHEN T1.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM shipping_method AS T1 INNER JOIN cust_order AS T2 ON T1.method_id = T2.shipping_method_id WHERE T2.order_date LIKE '2022-11-10%'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the average number of pages of David Coward's books? [/INST] | SELECT AVG(T1.num_pages) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'David Coward'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the cost of the slowest and least expensive shipping method? [/INST] | SELECT method_name FROM shipping_method ORDER BY cost ASC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the title of the first book that was published in 1900? [/INST] | SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1900' ORDER BY publication_date LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the full name of the customer who owns the "[email protected]" e-mail address? [/INST] | SELECT first_name, last_name FROM customer WHERE email = '[email protected]'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many orders in 2022 have Iran as their destinations? [/INST] | SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id INNER JOIN cust_order AS T3 ON T3.dest_address_id = T2.address_id WHERE T1.country_name = 'Iran' AND STRFTIME('%Y', T3.order_date) = '2022'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among Daisey Lamball's orders, how many were shipped via International shipping? [/INST] | SELECT COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Daisey' AND T1.last_name = 'Lamball' AND T3.method_name = 'International'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the full name of the customer who ordered the most books of all time? [/INST] | SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(*) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many orders did Antonia Poltun return? [/INST] | SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.status_value = 'Returned' AND T4.first_name = 'Antonia' AND T4.last_name = 'Poltun'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which shipping method is preferred by customers the most? [/INST] | SELECT T2.method_name FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id GROUP BY T2.method_name ORDER BY COUNT(T2.method_id) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many orders were delivered in 2021? [/INST] | SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2021'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the first book written by J.K Rowling? [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'J.K. Rowling' ORDER BY T1.publication_date ASC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books did A.R. Braunmuller write? [/INST] | SELECT COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id WHERE T1.author_name = 'A.R. Braunmuller'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the publisher who published Agatha Christie's first book? [/INST] | SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Agatha Christie' ORDER BY T1.publication_date ASC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List all the names of the books written by Danielle Steel. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Danielle Steel'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books by William Shakespeare were published by Penguin Classics? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'William Shakespeare' AND T4.publisher_name = 'Penguin Classics'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the publisher that published the most books? [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id GROUP BY T2.publisher_name ORDER BY COUNT(T2.publisher_id) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the total shipping cost of all the orders made by Page Holsey? Indicate how many of the said orders were ordered in 2022. [/INST] | SELECT SUM(T3.cost) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Page' AND T1.last_name = 'Holsey' AND STRFTIME('%Y', T2.order_date) = '2022'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the name of the publisher with publisher ID 22? [/INST] | SELECT publisher_name FROM publisher WHERE publisher_id = 22; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many of the books authored by Al Gore have less than 400 pages? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Al Gore' AND T1.num_pages < 400; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List the author's and publisher's name of the book published on July 10, 1997. [/INST] | SELECT T3.author_name, T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T1.publication_date = '1997-07-10'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the language of the book with ISBN 23755004321? [/INST] | SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.isbn13 = 23755004321; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the title of the most expensive book? [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id ORDER BY T2.price DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Calculate the total price of books ordered by customer named Lucas Wyldbore. [/INST] | SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List the ISBN of the book published in Spanish. [/INST] | SELECT T1.isbn13 FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'Spanish'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among the books that cost less than 1 dollar, how many were published by Berkley Trade? [/INST] | SELECT COUNT(*) FROM publisher AS T1 INNER JOIN book AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN order_line AS T3 ON T3.book_id = T2.book_id WHERE T1.publisher_name = 'Berkley' AND T3.price < 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List the title of the books purchased by the customer named Zia Roizin. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Zia' AND T4.last_name = 'Roizin'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Who authored the book with greatest number of pages? [/INST] | SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id ORDER BY T1.num_pages DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List the email of customers that bought the book titled Switch on the Night. [/INST] | SELECT T4.email FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.title = 'Switch on the Night'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List the author's name of the books published by Abrams. [/INST] | SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T4.publisher_name = 'Abrams'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the publisher name of the book titled The Illuminati? [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Illuminati'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: In books authored by Abraham Lincoln, what is the percentage of the books published in 1992? [/INST] | SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T1.publication_date) = '1992' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Abraham Lincoln'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Among the books published in 2004, list the name of the publisher of books with number of pages greater than 70% of the average number of pages of all books. [/INST] | SELECT T1.title, T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE STRFTIME('%Y', T1.publication_date) = '2004' AND T1.num_pages * 100 > ( SELECT AVG(num_pages) FROM book ) * 70; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Provide the contact email of Moss Zarb. [/INST] | SELECT email FROM customer WHERE first_name = 'Moss' AND last_name = 'Zarb'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Name the streets in Dallas. [/INST] | SELECT street_name FROM address WHERE city = 'Dallas'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which books were released by Orson Scott Card in 2001? [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Orson Scott Card' AND STRFTIME('%Y', T1.publication_date) = '2001'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Count the number of books written by Orson Scott Card. [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Orson Scott Card'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Provide the authors and titles of the books which have more than 3000 pages. [/INST] | SELECT T3.author_name, T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.num_pages > 3000; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Who wrote "The Prophet"? [/INST] | SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.title = 'The Prophet'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books were published by Ace Hardcover? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Ace Hardcover'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which publisher published Barry Eisler's book? [/INST] | SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Barry Eisler'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many books were published in Japanese? [/INST] | SELECT COUNT(T2.book_id) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Sum the total price of the orders for The Prophet book. [/INST] | SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id WHERE T2.title = 'The Prophet'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Provide the number of orders by Daisey Lamball in 2021. [/INST] | SELECT COUNT(*) FROM cust_order AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Daisey' AND T2.last_name = 'Lamball' AND STRFTIME('%Y', T1.order_date) = '2021'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many customers are from Australia? [/INST] | SELECT COUNT(*) FROM customer_address AS T1 INNER JOIN address AS T2 ON T2.address_id = T1.address_id INNER JOIN country AS T3 ON T3.country_id = T2.country_id WHERE T3.country_name = 'Australia'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many orders were delivered in December 2019? [/INST] | SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2019'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Provide the customers' names who ordered the Fantasmas. [/INST] | SELECT T4.first_name, T4.last_name FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.title = 'Fantasmas'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many percent of orders in 2020 used international shipping? [/INST] | SELECT CAST(SUM(CASE WHEN T2.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id WHERE STRFTIME('%Y', T1.order_date) = '2020'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List all the authors named "George". [/INST] | SELECT author_name FROM author WHERE author_name LIKE 'George%'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which year has the most customer orders? [/INST] | SELECT strftime('%Y', order_date) FROM cust_order GROUP BY strftime('%Y', order_date) ORDER BY COUNT(strftime('%Y', order_date)) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the average price for the order line? [/INST] | SELECT AVG(price) FROM order_line; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List all of the books that were published in 1995. [/INST] | SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1995'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What is the most common domain for the email address among all the customers? [/INST] | SELECT SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) AS ym FROM customer GROUP BY SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) ORDER BY COUNT(*) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many publishers have the word "book" in their name? [/INST] | SELECT COUNT(*) FROM publisher WHERE publisher_name LIKE '%book%'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Which language is the rarest among all the books? [/INST] | SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id GROUP BY T2.language_name ORDER BY COUNT(T2.language_name) ASC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: List all the order dates for the customer named "Adrian Kunzelmann". [/INST] | SELECT T3.order_date FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Adrian' AND T4.last_name = 'Kunzelmann'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: How many addresses are from the Philippines? [/INST] | SELECT COUNT(T2.country_id) FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Philippines'; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: Who is the author who wrote the most books? [/INST] | SELECT T1.author_name FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id GROUP BY T1.author_name ORDER BY COUNT(T2.author_id) DESC LIMIT 1; |
[INST] Here is a database schema:
address_status :
status_id [ INTEGER ] primary_key
address_status [ TEXT ]
author :
author_id [ INTEGER ] primary_key
author_name [ TEXT ]
book_language :
language_id [ INTEGER ] primary_key
language_code [ TEXT ]
language_name [ TEXT ]
country :
country_id [ INTEGER ] primary_key
country_name [ TEXT ]
address :
address_id [ INTEGER ] primary_key
street_number [ TEXT ]
street_name [ TEXT ]
city [ TEXT ]
country_id [ INTEGER ] address.country_id = country.country_id
customer :
customer_id [ INTEGER ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
email [ TEXT ]
customer_address :
customer_id [ INTEGER ] customer_address.customer_id = customer.customer_id
address_id [ INTEGER ] customer_address.address_id = address.address_id
status_id [ INTEGER ]
order_status :
status_id [ INTEGER ] primary_key
status_value [ TEXT ]
publisher :
publisher_id [ INTEGER ] primary_key
publisher_name [ TEXT ]
book :
book_id [ INTEGER ] primary_key
title [ TEXT ]
isbn13 [ TEXT ]
language_id [ INTEGER ] book.language_id = book_language.language_id
num_pages [ INTEGER ]
publication_date [ DATE ]
publisher_id [ INTEGER ] book.publisher_id = publisher.publisher_id
book_author :
book_id [ INTEGER ] book_author.book_id = book.book_id
author_id [ INTEGER ] book_author.author_id = author.author_id
shipping_method :
method_id [ INTEGER ] primary_key
method_name [ TEXT ]
cost [ REAL ]
cust_order :
order_id [ INTEGER ] primary_key
order_date [ DATETIME ]
customer_id [ INTEGER ]
shipping_method_id [ INTEGER ]
dest_address_id [ INTEGER ]
order_history :
history_id [ INTEGER ] primary_key
order_id [ INTEGER ]
status_id [ INTEGER ]
status_date [ DATETIME ]
order_line :
line_id [ INTEGER ] primary_key
order_id [ INTEGER ]
book_id [ INTEGER ]
price [ REAL ]
Please write me a SQL statement that answers the following question: What are the books published by "Harper Collins"? [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Harper Collins'; |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.