db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
1
673
SQL
stringlengths
23
804
schema
stringclasses
69 values
books
How many orders were returned in the year 2020?
returned refers to status_value = 'Returned'; in the year 2020 refers to status_date LIKE '%2020%'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the second-least common method of shipping?
method of shipping refers to method_name; least method refers to Min(Count(method_id))
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many of the customer addresses are inactive?
addresses are inactive refers to address_status = 'Inactive'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the book with the most orders?
books refers to title; the most orders refers to Max(Count(order_id))
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the address that received the most orders?
address refers to street_name, city; received the most orders refers to Max(count(dest_address_id))
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How much time does it take to update the status of order "2398"?
"2398" is the order_id; time =   Subtract(strftime('%Y', status_date), strftime('%Y', order_date)) AS "year" , Subtract(strftime('%m', status_date), strftime('%m', order_date)) AS "month", Subtract (strftime('%d', status_date), strftime('%d', order_date)) AS "day"
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which customer has the most addresses?
customer refers to first_name, last_name; the most address refers to Max(count(address_id))
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What percentage of the total prices of all orders are shipped internationally?
shipped internationally refers to method_name = 'International'; percentage = Divide (Sum(price where method_name = 'International'), Sum(price)) * 100
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List all the authors who wrote fewer pages than the average.
author refers to author_name; who wrote fewer pages than the average refers to num_pages < AVG(num_pages)
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 )
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Other than zero, what is the lowest price paid by a customer for an order?
other than 0 refers to price ! = 0; lowest price paid refers to Min(price)
SELECT MIN(price) FROM order_line WHERE price <> 0
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many customers have an address that is located in the city of Villeneuve-la-Garenne?
"Villeneuve-la-Garenne" is the city
SELECT COUNT(address_id) FROM address WHERE city = 'Villeneuve-la-Garenne'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many authors are named Adam?
authors named Adam refers to author_name LIKE 'Adam'
SELECT COUNT(*) FROM author WHERE author_name LIKE 'Adam%'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many customers use a Yahoo! Mail e-mail address?
Yahoo! Mail e-mail address refers to email LIKE '%@yahoo.com'
SELECT COUNT(*) FROM customer WHERE email LIKE '%@yahoo.com'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What are the city addresses of the customers located in the United States of America?
"United States of America" is the country_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many orders did Marcelia Goering place in 2021 that uses the Priority Shipping method?
in 2021 refers to substr(order_date, 1, 4) = '2021'; priority shipping method refers to method_name = 'Priority'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which books have the most expensive price?
most expensive book refers to Max(price)
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many customers ordered the book titled "Anleitung zum Zickigsein"
"Anleitung zum Zickigsein" is the title of the book
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the most expensive price paid by a customer for the book "Bite Me If You Can (Argeneau #6)"?
"Bite Me If You Can (Argeneau #6)" is the title of the book; most expensive price refers to Max(price)
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)'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many customers ordered the oldest book?
oldest book refers to Min(publiation_date)
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List all the titles of the Spanish books published by Alfaguara.
"Spanish" is the language_name; 'Alfaguara' is the publisher_name
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many customers ordered Stephen King's first book?
"Stephen King" is the author_name; first book refers to Min(publication_date)
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What are the languages of the first two published books?
first two published book refers to Min(publication_date); language refers to language_name
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Who published the book "The Secret Garden"?
"The Secret Garden" is the title of the book; who published the book refers to publisher_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Among the books that were published by Scholastic, how many were written by J.K Rowling?
"J.K Rowling" is the author_name; 'Scholastic' is the publisher_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What are the names of all the publishers who have published at least 30 books?
published at least 30 books refers to Count(book_id) > = 30
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Indicate the last number of each street.
street refers to street_name; last number of each street refers to Substr (street_number, -1)
SELECT street_number FROM address
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Indicate the complete address of customers located in Lazaro Cardenas.
complete address refers to street_number, street_name, city, country; "Lazaro Cardenas" is the city
SELECT street_number, street_name, city, country_id FROM address WHERE city = 'Lazaro Cardenas'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Indicate the ISBN13 of all the books that have less than 140 pages and more than 135.
ISBN13 refers to isbn13; less than 140 pages and more than 135 refers to num_pages > 135 AND num_pages < 140;
SELECT isbn13 FROM book WHERE num_pages < 140 AND num_pages > 135
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Indicate the title of the six books with the greatest potential value as collectibles.
greatest potential value refers to Min(publication_date)
SELECT title FROM book ORDER BY publication_date ASC LIMIT 6
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books were ordered in the last month of the year 2020?
ordered in last month of the year 2020 refers to Substr(order_date, 1, 7) = '2020-12'
SELECT COUNT(*) FROM cust_order WHERE order_date LIKE '2020-12%'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Indicate the full name of all customers whose last name begins with the letter K.
full name refers to first_name, last_name; last name begin with the letter 'K' refers to last_name LIKE 'K%'
SELECT first_name, last_name FROM customer WHERE last_name LIKE 'K%'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
In which cities are the customers of Costa Rica located?
"Costa Rica" is the country_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which customer addresses are no longer active?
no longer active refers to address_status = 'Inactive'; customer address refers to street_number, street_name, city
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the full name of the customers who live in Baiyin city?
full name refers to first_name, last_name; 'Baiyin' is the city
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the email of the customers who place their orders with priority method?
priority method refers to method_name = 'Priority'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
On what date did the customers who live at number 460 of their respective streets place their orders?
live at number 460 refers to street_number = '460'; date the customers placed their orders refers to order_date
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Identify by their id all the orders that have been cancelled.
have been cancelled refers to status_value = 'cancelled'; id refers to order_id
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the status of the orders placed on 04/10/2022?
placed on 04/10/2022 refers to SUBSTR(order_date, 1, 10) = '2022-04-10'; status of order refers to status_value
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%'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the highest price at which a customer bought the book 'The Prophet'?
"The Prophet" is the title of the book; highest price refers to Max(price)
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
On what dates were books ordered at a price of 16.54?
price of 16.54 refers to price = 16.54; dates the book ordered refers to order_date
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List the titles of all the books that Peter H. Smith wrote.
"Peter H.Smit" is the author_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books under 300 pages has HarperCollins Publishers published?
under 300 pages refers to num_pages < 300; 'HarperCollins Publishers" is the publisher_name
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books have been published in Japanese?
in Japanese refers to language_name = 'Japanese
SELECT COUNT(*) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the average number of pages in the books written by Jennifer Crusie?
"Jennifer Crusie" is the author_name; average number of pages refers to AVG(num_pages)
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What percentage of the orders placed by Kaleena were shipped by the international method?
shipped by international method refers to method_name = 'International'; percentage = Divide (Sum(method_name = 'International'), Count(method_name)) * 100
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Provide the full name of the customers who have ordered the book The Sorrows of Young Werther.
full name refers to first_name, last_name; 'The Sorrows of Young Werther' is the title of the book
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List every book that Ursola Purdy has ordered.
book refers to title
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Who is the author of the book with the biggest page count?
author refers to author_name, biggest page count refers to Max(num_pages)
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books written by Akira Watanabe are available on Gravity?
"Akira Watanabe" is the author_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Provide the full address of Ursola Purdy.
full address refers to street_number, street_name, city, country_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Who is the author of the book The Mystery in the Rocky Mountains?
author refers to author_name; 'The Mystery in the Rocky Mountains' is the title of the book
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Identify the publisher of the book Girls' Night In.
"Girls' Night In" is the title of the book; publisher is the publisher_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Name the publisher of the oldest book.
publisher refers to publisher_name;  oldest book refers to Min(publication_date)
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Identify the cost difference between Priority and Express shipping methods.
"Priority" and "Express" are both method_name; cost difference = Subtract (Sum(cost where method_name = 'Express'), Sum(cost where method_name 'Priority'))
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many orders have been cancelled in 2022?
cancelled refers to status_value = 'Cancelled'; in 2022 refers to SUBSTR(status_date, 1, 4) = '2022'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List all the books published by BBC Audiobooks.
"BBC Audiobooks" refers to publisher_name; books refers to title
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books were published in 2017?
published in 2017 refers to Substr(publication_date,1, 4) = '2017'
SELECT COUNT(*) FROM book WHERE STRFTIME('%Y', publication_date) = '2017'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Provide the International Standard Book Number of the book The Mystery in the Rocky Mountains.
International Standard Book Number refers to isbn13; 'The Mystery in the Rocky Mountains' is the title of the book
SELECT isbn13 FROM book WHERE title = 'The Mystery in the Rocky Mountains'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Among all orders updated in 2022, identify the percentage that has been returned.
order updated in 2022 refers to SUBSTR(status_date, 1, 4) = '2022'; has been returned refers to status_value = 'Returned'; percentage = Divide (Count(status_value = 'Returned'), Count(status_value)) * 100
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Among all addresses provided by customers, identify the percentage that are not in use anymore.
address not in use refers to address_status = 'Inactive'; percentage = Divide (Count(address_status = 'Inactive'), Count(address_status)) * 100
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many pages does 'Seaward' have?
"Seaward" is the title of the book; pages refers to num_pages
SELECT num_pages FROM book WHERE title = 'Seaward'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Who is the author of First Things First?
"First Things First" is the title of the book; author refers to author_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List all books authored by Tom Clancy.
"Tom Clancy" is the author_name; books refers title
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which book by Hirohiko Araki was published on 6/6/2006?
"Hirohiko Araki" is the author_name; on 6/6/2006 refers to publication_date = '2006-06-06'; which book refers to title
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Who is the publisher of Hitchhiker's Guide To The Galaxy: The Filming of the Douglas Adams classic?
"Hitchhiker's Guide To The Galaxy: The Filming of the Douglas Adams classic" is the title of the book; publisher refers to publisher_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List all books published by ADV Manga.
"ADV Manga" is the publisher_name; books refers to title
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Write the full name of the customers whose address is at 55 Dorton Pass, Huangqiao.
full name refers to first_name, last_name; '55' is the street_number, 'Dorton Pass' is the street_name; 'Huangqiao' is the city
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which country is 9 Green Ridge Point, Arendal located at?
"9" is the street_number; 'Green Reidge Point' is the street_name; 'Arendal' is the city
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List 10 addresses located in Poland.
"Polan" is the country_name; address refers to street_number, street_name, city
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the shipping method ordered by Nicolette Sadler at 6/29/2020 7:40:07 PM?
ordered at 6/29/2020 7:40:07 PM refers to order_date = '2020-06-29 19:40:07'; shipping method refers to method_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List all books written in Arabic.
"Arabic" is the language_name; book refers to title
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which language is 'El plan infinito' written in?
"El plan infinito" is the title of the book; language refers to language_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What percentage of books written by Hirohiko make up the number of books published by Viz Media?
"Hirohiko Araki" is the author_name; 'Viz Media' is the publisher_name; percentage = Divide (Count(author_name = 'Hirohiko Araki'), Count(book_id)) * 100
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the average number of book pages written by Zilpha Keatley Snyder?
"Zilpha Keatley Snyder" is the author_name; average number of book pages refers to AVG(num_pages)
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the full name of customer with email ckupis4@tamu.edu?
"ckupis4@tamu.edu" is the email of customer; full name refers to first_name, last_name
SELECT first_name, last_name FROM customer WHERE email = 'ckupis4@tamu.edu'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which book has the most number of pages?
books with the most number of pages refers to Max(num_pages)
SELECT title FROM book ORDER BY num_pages DESC LIMIT 1
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books were written by author A.J. Ayer?
"A.J. Ayer" is the author_name;
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Name the title of books written by author A.J.Ayer.
"A.J. Ayer" is the author_name;
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
The book name "The Season: A Candid Look at Broadway" was published by which publisher?
"The Season: A Candid Look at Broadway" is the  title of the book; publisher refers to publisher_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the average of English books among all books published by Carole Marsh Mysteries?
English book refers to language_name = 'English'; 'Carole Marsh Mysteries' is the publisher_name; average = Divide (Count(language_name = 'English'), Count(book_id))
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Name the title of the book with the most number of pages that was published from 1990 to 2000 by publisher Free Press.
books with the most number of pages refers to Max(num_pages); published from 1990 to 2000 refers to SUBSTR(publication_date, 1, 4) BETWEEN '1990' AND '2000'; 'Free Press' is the publisher_name
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the order price of the book "The Servant Leader" in 2003?
"The Servant Leader" is the title of the book; book in 2003 refers to SUBSTR(publication_date, 1, 4) = '2003'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the current address of customer Kandy?
current address refers to address_status = 1; address refers to street_number, street_name, city
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books were ordered by customer Kandy Adamec?
null
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many orders got returned in 2022?
orders got returned refers to status_value = 'Returned'; in 2022 refers to SUBSTR(status_date, 1, 4) = '2022'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Which country does the customer with the email "rturbitt2@geocities.jp" from?
"rturbitt2@geocities.jp" is the email of customer; country refers to country_name
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 = 'rturbitT2@geocities.jp'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Name the publisher who published the most books.
published the most books refers to Max(Count(book_id)); publisher refers to publisher_name
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the title of the first book that was written by A.J. Ayer?
"A.J. Ayer" is the author_name; first book refers to Min(publication_date)
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the percentage of books that cost greater than $10 and were ordered by customer Ruthanne Vatini?
cost greater than $10 refers to price > 10; percentage = Divide (Count(book_id where price >10), Count(book_id)) * 100; full name refers to the composition of first name, lastname
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List the title of books published by AK Press.
"AK Press" is the publisher_name
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Who ordered the book with the cheapest price?
book with cheapest price refers to Min(price); who order means name of customer which refers to first_name, last_name
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
List down the ISBN of the books purchased by the customer with an email of fsier3e@ihg.com.
"fsier3e@ihg.com" is the email of customer; ISBN refers to isbn13
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 = 'fsier3e@ihg.com'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Give the author's name of the books that cost 19 dollars and above.
books cost 19 dollars and above refers to price > = 19
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Provide the publisher name of the book with ISBN 76092025986.
"76092025986" is the isbn13
SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.isbn13 = 76092025986
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Among the books published by Birlinn in 2008, how many books have pages around 600 to 700?
"Birlinn" is the publisher_name; books have pages around 600 to 700 refers to num_pages BETWEEN 600 AND 700; in 2008 refers to SUBSTR(publication_date, 1, 4) = '2008'
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the price of the book with ISBN 9780763628321?
"9780763628321" is the isbn13
SELECT T2.price FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.isbn13 = 9780763628321
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
What is the number of pages of the book in the order ID 1167?
number of pages refers to num_pages
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Provide the title of the books published in British-English.
"British English" is the language_name of the book
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
How many books were published by Brava in 2006?
"Brava" is the publisher_name; in 2006 refers to SUBSTR(publication_date, 1, 4) = '2006'
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'
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,
books
Provide the ISBN and price of the book with book ID 7160.
ISBN refers to isbn13;
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
database name:db_id books address_status table address_status Cols: status id dtype integer, address status dtype text, author table author Cols: author id dtype integer, author name dtype text, book_language table book_language Cols: language id dtype integer, language code dtype text, language name dtype text, country table country Cols: country id dtype integer, country name dtype text, address table address Cols: address id dtype integer, street number dtype text, street name dtype text, city dtype text, country id dtype integer, customer table customer Cols: customer id dtype integer, first name dtype text, last name dtype text, email dtype text, customer_address table customer_address Cols: customer id dtype integer, address id dtype integer, status id dtype integer, order_status table order_status Cols: status id dtype integer, status value dtype text, publisher table publisher Cols: publisher id dtype integer, publisher name dtype text, book table book Cols: book id dtype integer, title dtype text, isbn13 dtype text, language id dtype integer, number pages dtype integer, publication date dtype date, publisher_id dtype integer, book_author table book_author Cols: book id dtype integer, author id dtype integer, shipping_method table shipping_method Cols: method id dtype integer, method name dtype text, cost dtype real, cust_order table cust_order Cols: order id dtype integer, order date dtype datetime, customer id dtype integer, shipping method id dtype integer, destination address id dtype integer, order_history table order_history Cols: history id dtype integer, order_id dtype integer, status id dtype integer, status date dtype datetime, order_line table order_line Cols: line id dtype integer, order id dtype integer, book id dtype integer, price dtype real,