Chinastark/bird_dataset huggingface dataset:
Database: books
Note: "Ace Hardcover" is the publisher_name;
Question: How many books were published by Ace Hardcover?
SQL: SELECT count(*) FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE publisher.publisher_name = 'Ace Hardcover'
Database: books
Note: "Barry Eisler" is the author_name; publisher refers to publisher_name;
Question: Which publisher published Barry Eisler's book?
SQL: SELECT publisher.publisher_name FROM book INNER JOIN book_author ON book.book_id = book_author.book_id INNER JOIN author ON author.author_id = book_author.author_id INNER JOIN publisher ON publisher.publisher_id = book.publisher_id WHERE author.author_name = 'Barry Eisler'
Database: books
Note: published in Japanese refers to language_name = 'Japanese';
Question: How many books were published in Japanese?
SQL: SELECT count(book.book_id) FROM book_language INNER JOIN book ON book_language.language_id = book.language_id WHERE book_language.language_name = 'Japanese'
Database: books
Note: "The Prophet" is the title of the book: total price refers to Sum(price);
Question: Sum the total price of the orders for The Prophet book.
SQL: SELECT sum(order_line.price) FROM order_line INNER JOIN book ON order_line.book_id = book.book_id WHERE book.title = 'The Prophet'
Database: books
Note: in 2021 refers to order_date LIKE '2021%';
Question: Provide the number of orders by Daisey Lamball in 2021.
SQL: SELECT count(*) FROM cust_order INNER JOIN customer ON cust_order.customer_id = customer.customer_id WHERE customer.first_name = 'Daisey' AND customer.last_name = 'Lamball' AND strftime('%Y', cust_order.order_date) = '2021'
Database: books
Note: "Australia" is the country_name;
Question: How many customers are from Australia?
SQL: SELECT count(*) FROM customer_address INNER JOIN address ON address.address_id = customer_address.address_id INNER JOIN country ON country.country_id = address.country_id WHERE country.country_name = 'Australia'
Database: books
Note: delivered refers to status_value = 'Delivered'; in December 2019 refers to status_date LIKE '2019-12%';
Question: How many orders were delivered in December 2019?
SQL: SELECT count(*) FROM order_status INNER JOIN order_history ON order_status.status_id = order_history.status_id WHERE order_status.status_value = 'Delivered' AND strftime('%Y', order_history.status_date) = '2019'
Database: books
Note: "Fantasmas" is the title of the book; customer names refers to first_name, last_name;
Question: Provide the customers' names who ordered the Fantasmas.
SQL: SELECT customer.first_name, customer.last_name FROM book INNER JOIN order_line ON book.book_id = order_line.book_id INNER JOIN cust_order ON cust_order.order_id = order_line.order_id INNER JOIN customer ON customer.customer_id = cust_order.customer_id WHERE book.title = 'Fantasmas'
Database: books
Note: international shipping refers to method_name = 'International'; orders in 2020 refers to order_date = '2020%'; percentage = Divide (Sum(method_name = 'International'), Count(order_id)) * 100;
Question: How many percent of orders in 2020 used international shipping?
SQL: SELECT cast(sum(CASE WHEN shipping_method.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) FROM cust_order INNER JOIN shipping_method ON cust_order.shipping_method_id = shipping_method.method_id WHERE strftime('%Y', cust_order.order_date) = '2020'
Database: books
Note: author named 'George' refers to author_name = 'George%';
Question: List all the authors named "George".
SQL: SELECT author_name FROM author WHERE author_name LIKE 'George%'
Database: books
Note: year with the most customer orders refers to Max(count(order_id));
Question: Which year has the most customer orders?
SQL: SELECT strftime('%Y', order_date) FROM cust_order GROUP BY strftime('%Y', order_date) ORDER BY count(strftime('%Y', order_date)) DESC LIMIT 1
Database: books
Note: average price refers to AVG(price);
Question: What is the average price for the order line?
SQL: SELECT avg(price) FROM order_line
Database: books
Note: published in 1995 refers to publication_date LIKE '1995%'; ; list of book refers to title;
Question: List all of the books that were published in 1995.
SQL: SELECT title FROM book WHERE strftime('%Y', publication_date) = '1995'
Database: books
Note: most common domain for the email refers to Max(Count(SUBSTR(email, CHARINDEX('@', email) + 1, length(email) - charindex('@', email))));
Question: What is the most common domain for the email address among all the customers?
SQL: 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
Database: books
Note: publisher have the word 'book' refers to publisher_name LIKE '%book%';
Question: How many publishers have the word "book" in their name?
SQL: SELECT count(*) FROM publisher WHERE publisher_name LIKE '%book%'
Database: books
Note: language written in refers to language_name; rarest refers to Min(Count(book_id));
Question: Which language is the rarest among all the books?
SQL: SELECT book_language.language_name FROM book INNER JOIN book_language ON book.language_id = book_language.language_id GROUP BY book_language.language_name ORDER BY count(book_language.language_name) ASC LIMIT 1
Database: books
Question: List all the order dates for the customer named "Adrian Kunzelmann".
SQL: SELECT cust_order.order_date FROM book INNER JOIN order_line ON book.book_id = order_line.book_id INNER JOIN cust_order ON cust_order.order_id = order_line.order_id INNER JOIN customer ON customer.customer_id = cust_order.customer_id WHERE customer.first_name = 'Adrian' AND customer.last_name = 'Kunzelmann'
Database: books
Note: "Philippines" is the country_name;
Question: How many addresses are from the Philippines?
SQL: SELECT count(country.country_id) FROM address INNER JOIN country ON country.country_id = address.country_id WHERE country.country_name = 'Philippines'
Database: books
Note: author refers to author_name; who wrote the most book refers to Max(Count(author_id));
Question: Who is the author who wrote the most books?
SQL: SELECT author.author_name FROM author INNER JOIN book_author ON author.author_id = book_author.author_id GROUP BY author.author_name ORDER BY count(book_author.author_id) DESC LIMIT 1
Database: books
Note: "Harper Collins" is the publisher_name; books refers to title;
Question: What are the books published by "Harper Collins"?
SQL: SELECT book.title FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE publisher.publisher_name = 'Harper Collins'
Database: books
Note: returned refers to status_value = 'Returned'; in the year 2020 refers to status_date LIKE '%2020%';
Question: How many orders were returned in the year 2020?
SQL: SELECT count(*) FROM order_status INNER JOIN order_history ON order_status.status_id = order_history.status_id WHERE order_status.status_value = 'Returned' AND strftime('%Y', order_history.status_date) = '2020'
Database: books
Note: method of shipping refers to method_name; least method refers to Min(Count(method_id));
Question: What is the second-least common method of shipping?
SQL: SELECT shipping_method.method_name FROM cust_order INNER JOIN shipping_method ON cust_order.shipping_method_id = shipping_method.method_id GROUP BY shipping_method.method_name ORDER BY count(shipping_method.method_id) ASC LIMIT 1, 1
Database: books
Note: addresses are inactive refers to address_status = 'Inactive';
Question: How many of the customer addresses are inactive?
SQL: SELECT count(*) FROM customer_address INNER JOIN address_status ON customer_address.status_id = address_status.status_id WHERE address_status.address_status = 'Inactive'
Database: books
Note: books refers to title; the most orders refers to Max(Count(order_id));
Question: What is the book with the most orders?
SQL: SELECT book.title FROM order_line INNER JOIN book ON order_line.book_id = book.book_id GROUP BY book.title ORDER BY count(order_line.book_id) DESC LIMIT 1
Database: books
Note: address refers to street_name, city; received the most orders refers to Max(count(dest_address_id));
Question: What is the address that received the most orders?
SQL: SELECT address.street_name, address.city FROM cust_order INNER JOIN address ON cust_order.dest_address_id = address.address_id GROUP BY address.street_number, address.street_name, address.city ORDER BY count(cust_order.dest_address_id) DESC LIMIT 1
Database: books
Note: "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";
Question: How much time does it take to update the status of order "2398"?
SQL: SELECT strftime('%J', order_history.status_date) - strftime('%J', cust_order.order_date) FROM cust_order INNER JOIN order_history ON cust_order.order_id = order_history.order_id WHERE cust_order.order_id = 2398
Database: books
Note: customer refers to first_name, last_name; the most address refers to Max(count(address_id));
Question: Which customer has the most addresses?
SQL: SELECT customer.first_name, customer.last_name FROM customer INNER JOIN customer_address ON customer.customer_id = customer_address.customer_id GROUP BY customer.first_name, customer.last_name ORDER BY count(customer_address.customer_id) DESC LIMIT 1
Database: books
Note: shipped internationally refers to method_name = 'International'; percentage = Divide (Sum(price where method_name = 'International'), Sum(price)) * 100;
Question: What percentage of the total prices of all orders are shipped internationally?
SQL: SELECT cast(sum(CASE WHEN shipping_method.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) FROM cust_order INNER JOIN order_line ON cust_order.order_id = order_line.order_id INNER JOIN shipping_method ON shipping_method.method_id = cust_order.shipping_method_id
Database: books
Note: author refers to author_name; who wrote fewer pages than the average refers to num_pages < AVG(num_pages);
Question: List all the authors who wrote fewer pages than the average.
SQL: SELECT author.author_name FROM book INNER JOIN book_author ON book.book_id = book_author.book_id INNER JOIN author ON author.author_id = book_author.author_id WHERE book.num_pages < ( SELECT avg(num_pages) FROM book )
Database: books
Note: other than 0 refers to price ! = 0; lowest price paid refers to Min(price);
Question: Other than zero, what is the lowest price paid by a customer for an order?
SQL: SELECT min(price) FROM order_line WHERE price <> 0
Database: books
Note: "Villeneuve-la-Garenne" is the city;
Question: How many customers have an address that is located in the city of Villeneuve-la-Garenne?
SQL: SELECT count(address_id) FROM address WHERE city = 'Villeneuve-la-Garenne'
Database: books
Note: authors named Adam refers to author_name LIKE 'Adam';
Question: How many authors are named Adam?
SQL: SELECT count(*) FROM author WHERE author_name LIKE 'Adam%'
Database: books
Note: Yahoo! Mail e-mail address refers to email LIKE '%@yahoo.com';
Question: How many customers use a Yahoo! Mail e-mail address?
SQL: SELECT count(*) FROM customer WHERE email LIKE '%@yahoo.com'
Database: books
Note: "United States of America" is the country_name;
Question: What are the city addresses of the customers located in the United States of America?
SQL: SELECT DISTINCT address.city FROM country INNER JOIN address ON country.country_id = address.country_id WHERE country.country_name = 'United States of America'
Database: books
Note: in 2021 refers to substr(order_date, 1, 4) = '2021'; priority shipping method refers to method_name = 'Priority';
Question: How many orders did Marcelia Goering place in 2021 that uses the Priority Shipping method?
SQL: SELECT count(*) FROM customer INNER JOIN cust_order ON customer.customer_id = cust_order.customer_id INNER JOIN shipping_method ON shipping_method.method_id = cust_order.shipping_method_id WHERE customer.first_name = 'Marcelia' AND customer.last_name = 'Goering' AND strftime('%Y', cust_order.order_date) = '2021' AND shipping_method.method_name = 'Priority'
Database: books
Note: most expensive book refers to Max(price);
Question: Which books have the most expensive price?
SQL: SELECT book.title FROM order_line INNER JOIN book ON order_line.book_id = book.book_id ORDER BY order_line.price DESC LIMIT 1
Database: books
Note: "Anleitung zum Zickigsein" is the title of the book;
Question: How many customers ordered the book titled "Anleitung zum Zickigsein"
SQL: SELECT count(*) FROM book INNER JOIN order_line ON book.book_id = order_line.book_id WHERE book.title = 'Anleitung zum Zickigsein'
Database: books
Note: "Bite Me If You Can (Argeneau #6)" is the title of the book; most expensive price refers to Max(price);
Question: What is the most expensive price paid by a customer for the book "Bite Me If You Can (Argeneau #6)"?
SQL: SELECT max(order_line.price) FROM book INNER JOIN order_line ON book.book_id = order_line.book_id WHERE book.title = 'Bite Me If You Can (Argeneau #6)'
Database: books
Note: oldest book refers to Min(publiation_date);
Question: How many customers ordered the oldest book?
SQL: SELECT count(*) FROM book INNER JOIN order_line ON book.book_id = order_line.book_id GROUP BY book.publication_date ORDER BY book.publication_date ASC LIMIT 1
Database: books
Note: "Spanish" is the language_name; 'Alfaguara' is the publisher_name;
Question: List all the titles of the Spanish books published by Alfaguara.
SQL: SELECT book.title FROM book_language INNER JOIN book ON book.language_id = book_language.language_id INNER JOIN publisher ON publisher.publisher_id = book.publisher_id WHERE book_language.language_name = 'Spanish' AND publisher.publisher_name = 'Alfaguara' GROUP BY book.title
Database: books
Note: "Stephen King" is the author_name; first book refers to Min(publication_date);
Question: How many customers ordered Stephen King's first book?
SQL: SELECT count(book.publication_date) FROM book INNER JOIN book_author ON book.book_id = book_author.book_id INNER JOIN author ON author.author_id = book_author.author_id INNER JOIN order_line ON order_line.book_id = book.book_id WHERE author.author_name = 'Stephen King' ORDER BY book.publication_date ASC LIMIT 1
Database: books
Note: first two published book refers to Min(publication_date); language refers to language_name;
Question: What are the languages of the first two published books?
SQL: SELECT book_language.language_name FROM book INNER JOIN book_language ON book.language_id = book_language.language_id ORDER BY book.publication_date ASC LIMIT 2
Database: books
Note: "The Secret Garden" is the title of the book; who published the book refers to publisher_name;
Question: Who published the book "The Secret Garden"?
SQL: SELECT DISTINCT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE book.title = 'The Secret Garden'
Database: books
Note: "J.K Rowling" is the author_name; 'Scholastic' is the publisher_name;
Question: Among the books that were published by Scholastic, how many were written by J.K Rowling?
SQL: SELECT count(*) FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id INNER JOIN book_author ON book_author.book_id = book.book_id INNER JOIN author ON author.author_id = book_author.author_id WHERE publisher.publisher_name = 'Scholastic' AND author.author_name = 'J.K. Rowling'
Database: books
Note: published at least 30 books refers to Count(book_id) >= 30;
Question: What are the names of all the publishers who have published at least 30 books?
SQL: SELECT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id GROUP BY publisher.publisher_name HAVING count(publisher.publisher_name) >= 30
Database: books
Note: street refers to street_name; last number of each street refers to Substr (street_number, -1);
Question: Indicate the last number of each street.
SQL: SELECT street_number FROM address
Database: books
Note: complete address refers to street_number, street_name, city, country; "Lazaro Cardenas" is the city;
Question: Indicate the complete address of customers located in Lazaro Cardenas.
SQL: SELECT street_number, street_name, city, country_id FROM address WHERE city = 'Lazaro Cardenas'
Database: books
Note: isbn13 refers to isbn13; less than 140 pages and more than 135 refers to num_pages > 135 AND num_pages < 140;
Question: Indicate the ISBN13 of all the books that have less than 140 pages and more than 135.
SQL: SELECT isbn13 FROM book WHERE num_pages < 140 AND num_pages > 135
Database: books
Note: greatest potential value refers to Min(publication_date);
Question: Indicate the title of the six books with the greatest potential value as collectibles.
SQL: SELECT title FROM book ORDER BY publication_date ASC LIMIT 6
Database: books
Note: ordered in last month of the year 2020 refers to Substr(order_date, 1, 7) = '2020-12';
Question: How many books were ordered in the last month of the year 2020?
SQL: SELECT count(*) FROM cust_order WHERE order_date LIKE '2020-12%'
Database: books
Note: full name refers to first_name, last_name; last name begin with the letter 'K' refers to last_name LIKE 'K%';
Question: Indicate the full name of all customers whose last name begins with the letter K.
SQL: SELECT first_name, last_name FROM customer WHERE last_name LIKE 'K%'
Database: books
Note: "costa Rica" is the country_name;
Question: In which cities are the customers of Costa Rica located?
SQL: SELECT address.city FROM address INNER JOIN country ON country.country_id = address.country_id WHERE country.country_name = 'Costa Rica'
Database: books
Note: no longer active refers to address_status = 'Inactive'; customer address refers to street_number, street_name, city;
Question: Which customer addresses are no longer active?
SQL: SELECT DISTINCT address.street_name FROM address INNER JOIN customer_address ON address.address_id = customer_address.address_id INNER JOIN address_status ON address_status.status_id = customer_address.status_id WHERE address_status.address_status = 'Inactive'
Database: books
Note: full name refers to first_name, last_name; 'Baiyin' is the city;
Question: What is the full name of the customers who live in Baiyin city?
SQL: SELECT customer.first_name, customer.last_name FROM address INNER JOIN customer_address ON address.address_id = customer_address.address_id INNER JOIN customer ON customer.customer_id = customer_address.customer_id WHERE address.city = 'Baiyin'
Database: books
Note: priority method refers to method_name = 'Priority';
Question: What is the email of the customers who place their orders with priority method?
SQL: SELECT customer.email FROM customer INNER JOIN cust_order ON customer.customer_id = cust_order.customer_id INNER JOIN shipping_method ON shipping_method.method_id = cust_order.shipping_method_id WHERE shipping_method.method_name = 'Priority'
Database: books
Note: live at number 460 refers to street_number = '460'; date the customers placed their orders refers to order_date;
Question: On what date did the customers who live at number 460 of their respective streets place their orders?
SQL: SELECT cust_order.order_date FROM cust_order INNER JOIN address ON cust_order.dest_address_id = address.address_id WHERE address.street_number = 460
Database: books
Note: have been cancelled refers to status_value = 'cancelled'; id refers to order_id;
Question: Identify by their id all the orders that have been cancelled.
SQL: SELECT order_history.order_id FROM order_status INNER JOIN order_history ON order_status.status_id = order_history.status_id WHERE order_status.status_value = 'Cancelled'
Database: books
Note: placed on 04/10/2022 refers to SUBSTR(order_date, 1, 10) = '2022-04-10'; status of order refers to status_value;
Question: What is the status of the orders placed on 04/10/2022?
SQL: SELECT DISTINCT order_status.status_value FROM order_status INNER JOIN order_history ON order_status.status_id = order_history.status_id INNER JOIN cust_order ON cust_order.order_id = order_history.order_id WHERE cust_order.order_date LIKE '2022-04-10%'
Database: books
Note: "The Prophet" is the title of the book; highest price refers to Max(price);
Question: What is the highest price at which a customer bought the book 'The Prophet'?
SQL: SELECT max(order_line.price) FROM book INNER JOIN order_line ON book.book_id = order_line.book_id WHERE book.title = 'The Prophet'
Database: books
Note: price of 16.54 refers to price = 16.54; dates the book ordered refers to order_date;
Question: On what dates were books ordered at a price of 16.54?
SQL: SELECT cust_order.order_date FROM cust_order INNER JOIN order_line ON cust_order.order_id = order_line.order_id WHERE order_line.price = 16.54
Database: books
Note: "Peter H.Smit" is the author_name;
Question: List the titles of all the books that Peter H. Smith wrote.
SQL: SELECT book.title FROM book INNER JOIN book_author ON book.book_id = book_author.book_id INNER JOIN author ON author.author_id = book_author.author_id WHERE author.author_name = 'Peter H. Smith'
Database: books
Note: under 300 pages refers to num_pages < 300; 'HarperCollins publishers" is the publisher_name;
Question: How many books under 300 pages has HarperCollins Publishers published?
SQL: SELECT count(*) FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE publisher.publisher_name = 'HarperCollins Publishers' AND book.num_pages < 300
Database: books
Note: in Japanese refers to language_name = 'Japanese;
Question: How many books have been published in Japanese?
SQL: SELECT count(*) FROM book_language INNER JOIN book ON book_language.language_id = book.language_id WHERE book_language.language_name = 'Japanese'
Database: books
Note: "Jennifer Crusie" is the author_name; average number of pages refers to AVG(num_pages);
Question: What is the average number of pages in the books written by Jennifer Crusie?
SQL: SELECT avg(book.num_pages) FROM book INNER JOIN book_author ON book.book_id = book_author.book_id INNER JOIN author ON author.author_id = book_author.author_id WHERE author.author_name = 'Jennifer Crusie'
Database: books
Note: shipped by international method refers to method_name = 'International'; percentage = Divide (Sum(method_name = 'International'), Count(method_name)) * 100;
Question: What percentage of the orders placed by Kaleena were shipped by the international method?
SQL: SELECT cast(sum(CASE WHEN shipping_method.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) FROM customer INNER JOIN cust_order ON customer.customer_id = cust_order.customer_id INNER JOIN shipping_method ON shipping_method.method_id = cust_order.shipping_method_id WHERE customer.first_name = 'Kaleena'
Database: books
Note: full name refers to first_name, last_name; 'The Sorrows of Young Werther' is the title of the book;
Question: Provide the full name of the customers who have ordered the book The Sorrows of Young Werther.
SQL: SELECT customer.first_name, customer.last_name FROM book INNER JOIN order_line ON book.book_id = order_line.book_id INNER JOIN cust_order ON cust_order.order_id = order_line.order_id INNER JOIN customer ON customer.customer_id = cust_order.customer_id WHERE book.title = 'The Sorrows of Young Werther'
Database: books
Note: book refers to title;
Question: List every book that Ursola Purdy has ordered.
SQL: SELECT book.title FROM book INNER JOIN order_line ON book.book_id = order_line.book_id INNER JOIN cust_order ON cust_order.order_id = order_line.order_id INNER JOIN customer ON customer.customer_id = cust_order.customer_id WHERE customer.first_name = 'Ursola' AND customer.last_name = 'Purdy'
Database: books
Note: author refers to author_name, biggest page count refers to Max(num_pages);
Question: Who is the author of the book with the biggest page count?
SQL: SELECT author.author_name FROM book INNER JOIN book_author ON book.book_id = book_author.book_id INNER JOIN author ON author.author_id = book_author.author_id ORDER BY book.num_pages DESC LIMIT 1