problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: How many books did David Foster Wallace write?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(T1.title) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'David Foster Wallace'
Write SQL query to solve given problem: How many orders does the book "O Xará" have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id WHERE T1.title = 'O Xará'
Write SQL query to solve given problem: Which country does Malina Johnson live in?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T4.country_name FROM customer AS T1 INNER JOIN customer_address AS T2 ON T1.customer_id = T2.customer_id INNER JOIN address AS T3 ON T3.address_id = T2.address_id INNER JOIN country AS T4 ON T4.country_id = T3.country_id WHERE T1.first_name = 'Malina' AND T1.last_name = 'Johnson' AND T2.status_id = 2
Write SQL query to solve given problem: Give the number of Ukrainian addresses in the database.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T1.country_name = 'Ukraine'
Write SQL query to solve given problem: Which country does Žirovnica city belong to?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.country_name FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id WHERE T2.city = 'Žirovnica'
Write SQL query to solve given problem: Calculate the percentage of the International shipping orders on 2022/11/10.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT CAST(SUM(CASE WHEN T1.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM shipping_method AS T1 INNER JOIN cust_order AS T2 ON T1.method_id = T2.shipping_method_id WHERE T2.order_date LIKE '2022-11-10%'
Write SQL query to solve given problem: What is the average number of pages of David Coward's books?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT AVG(T1.num_pages) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'David Coward'
Write SQL query to solve given problem: What is the cost of the slowest and least expensive shipping method?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT method_name FROM shipping_method ORDER BY cost ASC LIMIT 1
Write SQL query to solve given problem: What is the title of the first book that was published in 1900?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1900' ORDER BY publication_date LIMIT 1
Write SQL query to solve given problem: What is the full name of the customer who owns the "[email protected]" e-mail address?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT first_name, last_name FROM customer WHERE email = '[email protected]'
Write SQL query to solve given problem: How many orders in 2022 have Iran as their destinations?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM country AS T1 INNER JOIN address AS T2 ON T1.country_id = T2.country_id INNER JOIN cust_order AS T3 ON T3.dest_address_id = T2.address_id WHERE T1.country_name = 'Iran' AND STRFTIME('%Y', T3.order_date) = '2022'
Write SQL query to solve given problem: Among Daisey Lamball's orders, how many were shipped via International shipping?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Daisey' AND T1.last_name = 'Lamball' AND T3.method_name = 'International'
Write SQL query to solve given problem: What is the full name of the customer who ordered the most books of all time?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.first_name, T1.last_name ORDER BY COUNT(*) DESC LIMIT 1
Write SQL query to solve given problem: How many orders did Antonia Poltun return?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.status_value = 'Returned' AND T4.first_name = 'Antonia' AND T4.last_name = 'Poltun'
Write SQL query to solve given problem: Which shipping method is preferred by customers the most?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T2.method_name FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id GROUP BY T2.method_name ORDER BY COUNT(T2.method_id) DESC LIMIT 1
Write SQL query to solve given problem: How many orders were delivered in 2021?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2021'
Write SQL query to solve given problem: What is the name of the first book written by J.K Rowling?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'J.K. Rowling' ORDER BY T1.publication_date ASC LIMIT 1
Write SQL query to solve given problem: How many books did A.R. Braunmuller write?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id WHERE T1.author_name = 'A.R. Braunmuller'
Write SQL query to solve given problem: What is the name of the publisher who published Agatha Christie's first book?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Agatha Christie' ORDER BY T1.publication_date ASC LIMIT 1
Write SQL query to solve given problem: List all the names of the books written by Danielle Steel.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Danielle Steel'
Write SQL query to solve given problem: How many books by William Shakespeare were published by Penguin Classics?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'William Shakespeare' AND T4.publisher_name = 'Penguin Classics'
Write SQL query to solve given problem: What is the name of the publisher that published the most books?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: What is the total shipping cost of all the orders made by Page Holsey? Indicate how many of the said orders were ordered in 2022.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT SUM(T3.cost) FROM customer AS T1 INNER JOIN cust_order AS T2 ON T1.customer_id = T2.customer_id INNER JOIN shipping_method AS T3 ON T3.method_id = T2.shipping_method_id WHERE T1.first_name = 'Page' AND T1.last_name = 'Holsey' AND STRFTIME('%Y', T2.order_date) = '2022'
Write SQL query to solve given problem: What is the name of the publisher with publisher ID 22?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT publisher_name FROM publisher WHERE publisher_id = 22
Write SQL query to solve given problem: How many of the books authored by Al Gore have less than 400 pages?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Al Gore' AND T1.num_pages < 400
Write SQL query to solve given problem: List the author's and publisher's name of the book published on July 10, 1997.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T3.author_name, T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T1.publication_date = '1997-07-10'
Write SQL query to solve given problem: What is the language of the book with ISBN 23755004321?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T1.isbn13 = 23755004321
Write SQL query to solve given problem: What is the title of the most expensive book?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id ORDER BY T2.price DESC LIMIT 1
Write SQL query to solve given problem: Calculate the total price of books ordered by customer named Lucas Wyldbore.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN cust_order AS T2 ON T2.order_id = T1.order_id INNER JOIN customer AS T3 ON T3.customer_id = T2.customer_id WHERE T3.first_name = 'Lucas' AND T3.last_name = 'Wyldbore'
Write SQL query to solve given problem: List the ISBN of the book published in Spanish.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.isbn13 FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'Spanish'
Write SQL query to solve given problem: Among the books that cost less than 1 dollar, how many were published by Berkley Trade?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM publisher AS T1 INNER JOIN book AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN order_line AS T3 ON T3.book_id = T2.book_id WHERE T1.publisher_name = 'Berkley' AND T3.price < 1
Write SQL query to solve given problem: List the title of the books purchased by the customer named Zia Roizin.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Zia' AND T4.last_name = 'Roizin'
Write SQL query to solve given problem: Who authored the book with greatest number of pages?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: List the email of customers that bought the book titled Switch on the Night.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T4.email FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.title = 'Switch on the Night'
Write SQL query to solve given problem: List the author's name of the books published by Abrams.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T4.publisher_name = 'Abrams'
Write SQL query to solve given problem: What is the publisher name of the book titled The Illuminati?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Illuminati'
Write SQL query to solve given problem: In books authored by Abraham Lincoln, what is the percentage of the books published in 1992?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T1.publication_date) = '1992' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Abraham Lincoln'
Write SQL query to solve given problem: Among the books published in 2004, list the name of the publisher of books with number of pages greater than 70% of the average number of pages of all books.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title, T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE STRFTIME('%Y', T1.publication_date) = '2004' AND T1.num_pages * 100 > ( SELECT AVG(num_pages) FROM book ) * 70
Write SQL query to solve given problem: Provide the contact email of Moss Zarb.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT email FROM customer WHERE first_name = 'Moss' AND last_name = 'Zarb'
Write SQL query to solve given problem: Name the streets in Dallas.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT street_name FROM address WHERE city = 'Dallas'
Write SQL query to solve given problem: Which books were released by Orson Scott Card in 2001?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Orson Scott Card' AND STRFTIME('%Y', T1.publication_date) = '2001'
Write SQL query to solve given problem: Count the number of books written by Orson Scott Card.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Orson Scott Card'
Write SQL query to solve given problem: Provide the authors and titles of the books which have more than 3000 pages.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T3.author_name, T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.num_pages > 3000
Write SQL query to solve given problem: Who wrote "The Prophet"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.title = 'The Prophet'
Write SQL query to solve given problem: How many books were published by Ace Hardcover?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Ace Hardcover'
Write SQL query to solve given problem: Which publisher published Barry Eisler's book?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T4.publisher_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T3.author_name = 'Barry Eisler'
Write SQL query to solve given problem: How many books were published in Japanese?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(T2.book_id) FROM book_language AS T1 INNER JOIN book AS T2 ON T1.language_id = T2.language_id WHERE T1.language_name = 'Japanese'
Write SQL query to solve given problem: Sum the total price of the orders for The Prophet book.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT SUM(T1.price) FROM order_line AS T1 INNER JOIN book AS T2 ON T1.book_id = T2.book_id WHERE T2.title = 'The Prophet'
Write SQL query to solve given problem: Provide the number of orders by Daisey Lamball in 2021.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM cust_order AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Daisey' AND T2.last_name = 'Lamball' AND STRFTIME('%Y', T1.order_date) = '2021'
Write SQL query to solve given problem: How many customers are from Australia?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM customer_address AS T1 INNER JOIN address AS T2 ON T2.address_id = T1.address_id INNER JOIN country AS T3 ON T3.country_id = T2.country_id WHERE T3.country_name = 'Australia'
Write SQL query to solve given problem: How many orders were delivered in December 2019?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM order_status AS T1 INNER JOIN order_history AS T2 ON T1.status_id = T2.status_id WHERE T1.status_value = 'Delivered' AND STRFTIME('%Y', T2.status_date) = '2019'
Write SQL query to solve given problem: Provide the customers' names who ordered the Fantasmas.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T4.first_name, T4.last_name FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.title = 'Fantasmas'
Write SQL query to solve given problem: How many percent of orders in 2020 used international shipping?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT CAST(SUM(CASE WHEN T2.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM cust_order AS T1 INNER JOIN shipping_method AS T2 ON T1.shipping_method_id = T2.method_id WHERE STRFTIME('%Y', T1.order_date) = '2020'
Write SQL query to solve given problem: List all the authors named "George".. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT author_name FROM author WHERE author_name LIKE 'George%'
Write SQL query to solve given problem: Which year has the most customer orders?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT strftime('%Y', order_date) FROM cust_order GROUP BY strftime('%Y', order_date) ORDER BY COUNT(strftime('%Y', order_date)) DESC LIMIT 1
Write SQL query to solve given problem: What is the average price for the order line?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT AVG(price) FROM order_line
Write SQL query to solve given problem: List all of the books that were published in 1995.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT title FROM book WHERE STRFTIME('%Y', publication_date) = '1995'
Write SQL query to solve given problem: What is the most common domain for the email address among all the customers?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) AS ym FROM customer GROUP BY SUBSTR(email, INSTR(email, '@') + 1, LENGTH(email) - INSTR(email, '@')) ORDER BY COUNT(*) DESC LIMIT 1
Write SQL query to solve given problem: How many publishers have the word "book" in their name?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM publisher WHERE publisher_name LIKE '%book%'
Write SQL query to solve given problem: Which language is the rarest among all the books?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T2.language_name FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id GROUP BY T2.language_name ORDER BY COUNT(T2.language_name) ASC LIMIT 1
Write SQL query to solve given problem: List all the order dates for the customer named "Adrian Kunzelmann".. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T3.order_date FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Adrian' AND T4.last_name = 'Kunzelmann'
Write SQL query to solve given problem: How many addresses are from the Philippines?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(T2.country_id) FROM address AS T1 INNER JOIN country AS T2 ON T2.country_id = T1.country_id WHERE T2.country_name = 'Philippines'
Write SQL query to solve given problem: Who is the author who wrote the most books?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.author_name FROM author AS T1 INNER JOIN book_author AS T2 ON T1.author_id = T2.author_id GROUP BY T1.author_name ORDER BY COUNT(T2.author_id) DESC LIMIT 1
Write SQL query to solve given problem: What are the books published by "Harper Collins"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT T1.title FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Harper Collins'
Write SQL query to solve given problem: How many orders were returned in the year 2020?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: What is the second-least common method of shipping?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: How many of the customer addresses are inactive?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: What is the book with the most orders?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: What is the address that received the most orders?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: How much time does it take to update the status of order "2398"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: Which customer has the most addresses?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: What percentage of the total prices of all orders are shipped internationally?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: List all the authors who wrote fewer pages than the average.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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 )
Write SQL query to solve given problem: Other than zero, what is the lowest price paid by a customer for an order?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT MIN(price) FROM order_line WHERE price <> 0
Write SQL query to solve given problem: How many customers have an address that is located in the city of Villeneuve-la-Garenne?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(address_id) FROM address WHERE city = 'Villeneuve-la-Garenne'
Write SQL query to solve given problem: How many authors are named Adam?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM author WHERE author_name LIKE 'Adam%'
Write SQL query to solve given problem: How many customers use a Yahoo! Mail e-mail address?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM customer WHERE email LIKE '%@yahoo.com'
Write SQL query to solve given problem: What are the city addresses of the customers located in the United States of America?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: How many orders did Marcelia Goering place in 2021 that uses the Priority Shipping method?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: Which books have the most expensive price?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: How many customers ordered the book titled "Anleitung zum Zickigsein". Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: What is the most expensive price paid by a customer for the book "Bite Me If You Can (Argeneau #6)"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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)'
Write SQL query to solve given problem: How many customers ordered the oldest book?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: List all the titles of the Spanish books published by Alfaguara.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: How many customers ordered Stephen King's first book?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: What are the languages of the first two published books?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: Who published the book "The Secret Garden"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: Among the books that were published by Scholastic, how many were written by J.K Rowling?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: What are the names of all the publishers who have published at least 30 books?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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
Write SQL query to solve given problem: Indicate the last number of each street.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT street_number FROM address
Write SQL query to solve given problem: Indicate the complete address of customers located in Lazaro Cardenas.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT street_number, street_name, city, country_id FROM address WHERE city = 'Lazaro Cardenas'
Write SQL query to solve given problem: Indicate the ISBN13 of all the books that have less than 140 pages and more than 135.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT isbn13 FROM book WHERE num_pages < 140 AND num_pages > 135
Write SQL query to solve given problem: Indicate the title of the six books with the greatest potential value as collectibles.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT title FROM book ORDER BY publication_date ASC LIMIT 6
Write SQL query to solve given problem: How many books were ordered in the last month of the year 2020?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT COUNT(*) FROM cust_order WHERE order_date LIKE '2020-12%'
Write SQL query to solve given problem: Indicate the full name of all customers whose last name begins with the letter K.. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
SELECT first_name, last_name FROM customer WHERE last_name LIKE 'K%'
Write SQL query to solve given problem: In which cities are the customers of Costa Rica located?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: Which customer addresses are no longer active?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: What is the full name of the customers who live in Baiyin city?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: What is the email of the customers who place their orders with priority method?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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'
Write SQL query to solve given problem: On what date did the customers who live at number 460 of their respective streets place their orders?. Keep the solution inside sql tag ```sql [SQL-Query] ```
books
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