input
stringlengths 358
16.1k
| output
stringlengths 24
805
|
---|---|
[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 returned in the year 2020? [/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 = 'Returned' AND STRFTIME('%Y', T2.status_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: What is the second-least common method of shipping? [/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) ASC LIMIT 1, 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 of the customer addresses are inactive? [/INST] | SELECT COUNT(*) FROM customer_address AS T1 INNER JOIN address_status AS T2 ON T1.status_id = T2.status_id WHERE T2.address_status = 'Inactive'; |
[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 book with the most orders? [/INST] | SELECT T2.title FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id GROUP BY T2.title 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: What is the address that received the most orders? [/INST] | SELECT T2.street_name, T2.city FROM cust_order AS T1 INNER JOIN address AS T2 ON T1.dest_address_id = T2.address_id GROUP BY T2.street_number, T2.street_name, T2.city ORDER BY COUNT(T1.dest_address_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 much time does it take to update the status of order "2398"? [/INST] | SELECT strftime('%J', T2.status_date) - strftime('%J', T1.order_date) FROM cust_order AS T1 INNER JOIN order_history AS T2 ON T1.order_id = T2.order_id WHERE T1.order_id = 2398; |
[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 the most addresses? [/INST] | SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN customer_address AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(T2.customer_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 percentage of the total prices of all orders are shipped internationally? [/INST] | SELECT CAST(SUM(CASE WHEN T3.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM cust_order AS T1 INNER JOIN order_line AS T2 ON T1.order_id = T2.order_id INNER JOIN shipping_method AS T3 ON T3.method_id = T1.shipping_method_id; |
[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 who wrote fewer pages than the average. [/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.num_pages < ( SELECT AVG(num_pages) FROM 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: Other than zero, what is the lowest price paid by a customer for an order? [/INST] | SELECT MIN(price) FROM order_line WHERE price <> 0; |
[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 have an address that is located in the city of Villeneuve-la-Garenne? [/INST] | SELECT COUNT(address_id) FROM address WHERE city = 'Villeneuve-la-Garenne'; |
[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 authors are named Adam? [/INST] | SELECT COUNT(*) FROM author WHERE author_name LIKE 'Adam%'; |
[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 use a Yahoo! Mail e-mail address? [/INST] | SELECT COUNT(*) FROM customer WHERE email LIKE '%@yahoo.com'; |
[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 city addresses of the customers located in the United States of America? [/INST] | SELECT DISTINCT T2.city FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T1.country_name = 'United States of America'; |
[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 Marcelia Goering place in 2021 that uses the Priority Shipping method? [/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 = 'Marcelia' AND T1.last_name = 'Goering' AND STRFTIME('%Y', T2.order_date) = '2021' AND T3.method_name = 'Priority'; |
[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 have the most expensive price? [/INST] | SELECT T2.title FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id ORDER BY T1.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: How many customers ordered the book titled "Anleitung zum Zickigsein" [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'Anleitung zum Zickigsein'; |
[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 expensive price paid by a customer for the book "Bite Me If You Can (Argeneau #6)"? [/INST] | SELECT MAX(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'Bite Me If You Can (Argeneau #6)'; |
[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 ordered the oldest book? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id GROUP BY T1.publication_date 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 titles of the Spanish books published by Alfaguara. [/INST] | SELECT T2.title FROM book_language AS T1 INNER JOIN book AS T2 ON T2.language_id = T1.language_id INNER JOIN publisher AS T3 ON T3.publisher_id = T2.publisher_id WHERE T1.language_name = 'Spanish' AND T3.publisher_name = 'Alfaguara' GROUP BY T2.title; |
[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 ordered Stephen King's first book? [/INST] | SELECT COUNT(T1.publication_date) 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 order_line AS T4 ON T4.book_id = T1.book_id WHERE T3.author_name = 'Stephen King' 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: What are the languages of the first two published books? [/INST] | SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id ORDER BY T1.publication_date ASC LIMIT 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: Who published the book "The Secret Garden"? [/INST] | SELECT DISTINCT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Secret Garden'; |
[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 were published by Scholastic, how many were written by J.K Rowling? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN book_author AS T3 ON T3.book_id = T1.book_id INNER JOIN author AS T4 ON T4.author_id = T3.author_id WHERE T2.publisher_name = 'Scholastic' AND T4.author_name = 'J.K. Rowling'; |
[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 names of all the publishers who have published at least 30 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 HAVING COUNT(T2.publisher_name) >= 30; |
[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: Indicate the last number of each street. [/INST] | SELECT street_number FROM address; |
[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: Indicate the complete address of customers located in Lazaro Cardenas. [/INST] | SELECT street_number, street_name, city, country_id FROM address WHERE city = 'Lazaro Cardenas'; |
[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: Indicate the ISBN13 of all the books that have less than 140 pages and more than 135. [/INST] | SELECT isbn13 FROM book WHERE num_pages < 140 AND num_pages > 135; |
[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: Indicate the title of the six books with the greatest potential value as collectibles. [/INST] | SELECT title FROM book ORDER BY publication_date ASC LIMIT 6; |
[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 ordered in the last month of the year 2020? [/INST] | SELECT COUNT(*) FROM cust_order WHERE order_date LIKE '2020-12%'; |
[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: Indicate the full name of all customers whose last name begins with the letter K. [/INST] | SELECT first_name, last_name FROM customer WHERE last_name LIKE 'K%'; |
[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 which cities are the customers of Costa Rica located? [/INST] | SELECT T1.city FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Costa Rica'; |
[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 addresses are no longer active? [/INST] | SELECT DISTINCT T1.street_name FROM address AS T1 INNER JOIN customer_address AS T2 ON T1.address_id = T2.address_id INNER JOIN address_status AS T3 ON T3.status_id = T2.status_id WHERE T3.address_status = 'Inactive'; |
[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 customers who live in Baiyin city? [/INST] | SELECT T3.first_name, T3.last_name FROM address AS T1 INNER JOIN customer_address AS T2 ON T1.address_id = T2.address_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T1.city = 'Baiyin'; |
[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 email of the customers who place their orders with priority method? [/INST] | SELECT T1.email 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 T3.method_name = 'Priority'; |
[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: On what date did the customers who live at number 460 of their respective streets place their orders? [/INST] | SELECT T1.order_date FROM cust_order AS T1 INNER JOIN address AS T2 ON T1.dest_address_id = T2.address_id WHERE T2.street_number = 460; |
[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: Identify by their id all the orders that have been cancelled. [/INST] | SELECT T2.order_id FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Cancelled'; |
[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 status of the orders placed on 04/10/2022? [/INST] | SELECT DISTINCT T1.status_value 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 WHERE T3.order_date LIKE '2022-04-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 highest price at which a customer bought the book 'The Prophet'? [/INST] | SELECT MAX(T2.price) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_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: On what dates were books ordered at a price of 16.54? [/INST] | SELECT T1.order_date FROM cust_order AS T1 INNER JOIN order_line AS T2 ON T1.order_id = T2.order_id WHERE T2.price = 16.54; |
[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 titles of all the books that Peter H. Smith wrote. [/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 = 'Peter H. Smith'; |
[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 under 300 pages has HarperCollins Publishers published? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'HarperCollins Publishers' 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: How many books have been published in Japanese? [/INST] | SELECT COUNT(*) 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: What is the average number of pages in the books written by Jennifer Crusie? [/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 = 'Jennifer Crusie'; |
[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 percentage of the orders placed by Kaleena were shipped by the international method? [/INST] | SELECT CAST(SUM(CASE WHEN T3.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / 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 = 'Kaleena'; |
[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 full name of the customers who have ordered the book The Sorrows of Young Werther. [/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 = 'The Sorrows of Young Werther'; |
[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 every book that Ursola Purdy 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 = 'Ursola' AND T4.last_name = 'Purdy'; |
[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 of the book with the biggest page count? [/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: How many books written by Akira Watanabe are available on Gravity? [/INST] | SELECT COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id WHERE T1.author_name = 'Akira Watanabe'; |
[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 full address of Ursola Purdy. [/INST] | SELECT T3.street_number, T3.street_name, T3.city 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 = 'Ursola' AND T1.last_name = 'Purdy'; |
[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 of the book The Mystery in the Rocky Mountains? [/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 Mystery in the Rocky Mountains'; |
[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: Identify the publisher of the book Girls' Night In. [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'Girls'' Night In'; |
[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 publisher of the oldest book. [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id 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: Identify the cost difference between Priority and Express shipping methods. [/INST] | SELECT SUM(CASE WHEN method_name = 'Priority' THEN cost ELSE 0 END) - SUM(CASE WHEN method_name = 'Express' THEN cost ELSE 0 END) FROM shipping_method; |
[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 have been cancelled in 2022? [/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 = 'Cancelled' AND STRFTIME('%Y', T2.status_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: List all the books published by BBC Audiobooks. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'BBC Audiobooks'; |
[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 2017? [/INST] | SELECT COUNT(*) FROM book WHERE STRFTIME('%Y', publication_date) = '2017'; |
[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 International Standard Book Number of the book The Mystery in the Rocky Mountains. [/INST] | SELECT isbn13 FROM book WHERE title = 'The Mystery in the Rocky Mountains'; |
[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 all orders updated in 2022, identify the percentage that has been returned. [/INST] | SELECT CAST(SUM(CASE WHEN T1.status_value = 'Returned' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE STRFTIME('%Y', T2.status_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 all addresses provided by customers, identify the percentage that are not in use anymore. [/INST] | SELECT CAST(SUM(CASE WHEN T2.address_status = 'Inactive' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM customer_address AS T1 INNER JOIN address_status AS T2 ON T2.status_id = T1.status_id; |
[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 pages does 'Seaward' have? [/INST] | SELECT num_pages FROM book WHERE title = 'Seaward'; |
[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 of First Things First? [/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 = 'First Things First'; |
[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 books authored by Tom Clancy. [/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 = 'Tom Clancy'; |
[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 book by Hirohiko Araki was published on 6/6/2006? [/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 = 'Hirohiko Araki' AND T1.publication_date = '2006-06-06'; |
[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 publisher of Hitchhiker's Guide To The Galaxy: The Filming of the Douglas Adams classic? [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'Hitchhiker''s Guide To The Galaxy: The Filming of the Douglas Adams classic'; |
[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 books published by ADV Manga. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'ADV Manga'; |
[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: Write the full name of the customers whose address is at 55 Dorton Pass, Huangqiao. [/INST] | SELECT DISTINCT T1.first_name, T1.last_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 WHERE T3.street_number = 55 AND T3.street_name = 'Dorton Pass' AND T3.city = 'Huangqiao'; |
[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 is 9 Green Ridge Point, Arendal located at? [/INST] | SELECT T2.country_name FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T1.street_number = 9 AND T1.street_name = 'Green Ridge Point' AND T1.city = 'Arendal'; |
[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 10 addresses located in Poland. [/INST] | SELECT T1.street_number, T1.street_name, T1.city FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Poland' LIMIT 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 shipping method ordered by Nicolette Sadler at 6/29/2020 7:40:07 PM? [/INST] | SELECT T3.method_name FROM cust_order AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T1.shipping_method_id WHERE T2.first_name = 'Nicolette' AND T2.last_name = 'Sadler' AND T1.order_date = '2020-06-29 19:40:07'; |
[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 books written in Arabic. [/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 = 'Arabic'; |
[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 'El plan infinito' 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.title = 'El plan infinito'; |
[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 percentage of books written by Hirohiko make up the number of books published by Viz Media? [/INST] | SELECT CAST(SUM(CASE WHEN T1.author_name = 'Hirohiko Araki' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T2.author_id = T1.author_id INNER JOIN book AS T3 ON T3.book_id = T2.book_id INNER JOIN publisher AS T4 ON T4.publisher_id = T3.publisher_id WHERE T4.publisher_name = 'VIZ Media'; |
[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 book pages written by Zilpha Keatley Snyder? [/INST] | SELECT AVG(T3.num_pages) FROM book_author AS T1 INNER JOIN author AS T2 ON T1.author_id = T2.author_id INNER JOIN book AS T3 ON T3.book_id = T1.book_id WHERE T2.author_name = 'Zilpha Keatley Snyder'; |
[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 customer with email [email protected]? [/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: Which book has the most number of pages? [/INST] | SELECT title 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: How many books were written by author A.J. Ayer? [/INST] | SELECT COUNT(*) FROM book_author AS T1 INNER JOIN author AS T2 ON T1.author_id = T2.author_id WHERE T2.author_name = 'A.J. Ayer'; |
[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 title of books written by author A.J.Ayer. [/INST] | SELECT T3.title FROM book_author AS T1 INNER JOIN author AS T2 ON T1.author_id = T2.author_id INNER JOIN book AS T3 ON T3.book_id = T1.book_id WHERE T2.author_name = 'A.J. Ayer'; |
[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: The book name "The Season: A Candid Look at Broadway" was published by which publisher? [/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 Season: A Candid Look at Broadway'; |
[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 of English books among all books published by Carole Marsh Mysteries? [/INST] | SELECT CAST(SUM(CASE WHEN T1.language_name = 'English' THEN 1 ELSE 0 END) AS REAL) / COUNT(*) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id INNER JOIN publisher AS T3 ON T3.publisher_id = T2.publisher_id WHERE T3.publisher_name = 'Carole Marsh Mysteries'; |
[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 title of the book with the most number of pages that was published from 1990 to 2000 by publisher Free Press. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Free Press' AND STRFTIME('%Y', T1.publication_date) BETWEEN '1990' AND '2000' 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: What is the order price of the book "The Servant Leader" in 2003? [/INST] | SELECT T2.price FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'The Servant Leader' AND STRFTIME('%Y', T1.publication_date) = '2003'; |
[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 current address of customer Kandy? [/INST] | SELECT T3.street_number, T3.street_name, T3.city 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 address_status AS T4 ON T4.status_id = T2.status_id WHERE T1.first_name = 'Kandy'; |
[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 ordered by customer Kandy Adamec? [/INST] | SELECT 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 = 'Kandy' AND T3.last_name = 'Adamec'; |
[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 got returned in 2022? [/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 = 'Returned' AND STRFTIME('%Y', T2.status_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: Which country does the customer with the email "[email protected]" from? [/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.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: Name the publisher who 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 title of the first book that was written by A.J. Ayer? [/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 = 'A.J. Ayer' 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: What is the percentage of books that cost greater than $10 and were ordered by customer Ruthanne Vatini? [/INST] | SELECT CAST(SUM(CASE WHEN T1.price > 10 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 = 'Ruthanne' AND T3.last_name = 'Vatini'; |
[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 books published by AK Press. [/INST] | SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'AK Press'; |
[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 ordered the book with the cheapest price? [/INST] | SELECT T3.first_name, T3.last_name 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 ORDER BY T1.price 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 down the ISBN of the books purchased by the customer with an email of [email protected]. [/INST] | SELECT T1.isbn13 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.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: Give the author's name of the books that cost 19 dollars and above. [/INST] | SELECT DISTINCT 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 order_line AS T4 ON T4.book_id = T1.book_id WHERE T4.price > 19; |
[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 publisher name of the book with ISBN 76092025986. [/INST] | SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.isbn13 = 76092025986; |
[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 Birlinn in 2008, how many books have pages around 600 to 700? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Birlinn' AND STRFTIME('%Y', T1.publication_date) = '2008' AND T1.num_pages BETWEEN 600 AND 700; |
[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 price of the book with ISBN 9780763628321? [/INST] | SELECT T2.price FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.isbn13 = 9780763628321; |
[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 number of pages of the book in the order ID 1167? [/INST] | SELECT T1.num_pages FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T2.order_id = 1167; |
[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 title of the books published in British-English. [/INST] | SELECT DISTINCT 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: How many books were published by Brava in 2006? [/INST] | SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Brava' AND STRFTIME('%Y', T1.publication_date) = '2006'; |
[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 ISBN and price of the book with book ID 7160. [/INST] | SELECT T1.isbn13, T2.price FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T2.book_id = 6503; |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.