Chinastark/bird_dataset huggingface dataset:
Database: books
Note: name of publisher refers to publisher_name; publisher published the most number of books refers to Max(Count(book_id));
Question: What is the name of the publisher that has published the most number of books?
SQL: SELECT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id GROUP BY publisher.publisher_name ORDER BY count(book.book_id) DESC LIMIT 1
Database: books
Note: "Thomas Nelson" is the publisher_name; oldest book refers to Min(publication_date);
Question: Please give the title of the oldest book published by publisher "Thomas Nelson".
SQL: SELECT book.title FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE publisher.publisher_name = 'Thomas Nelson' ORDER BY book.publication_date ASC LIMIT 1
Database: books
Note: "Thomas Nelson" is the publisher_name; books with over 300 pages refers to num_pages > 300;
Question: Among the books published by publisher "Thomas Nelson", how many of them have over 300 pages?
SQL: SELECT count(*) FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE publisher.publisher_name = 'Thomas Nelson' AND book.num_pages > 300
Database: books
Note: book with the most pages refers to Max(num_pages); name of publisher refers to publisher_name;
Question: What is the name of the publisher of the book with the most pages?
SQL: SELECT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id ORDER BY book.num_pages DESC LIMIT 1
Database: books
Note: books in English refers to language_name = 'English';
Question: How many books are in English?
SQL: SELECT count(*) FROM book INNER JOIN book_language ON book.language_id = book_language.language_id WHERE book_language.language_name = 'English'
Database: books
Note: "British English" is the language_name of the book;
Question: Please list the titles of all the books in British English.
SQL: SELECT book.title FROM book INNER JOIN book_language ON book.language_id = book_language.language_id WHERE book_language.language_name = 'British English'
Database: books
Note: "The Little House" is the title of book; cheapest order price refers to Min(price);
Question: What is the cheapest order price of the book "The Little House"?
SQL: SELECT min(order_line.price) FROM book INNER JOIN order_line ON book.book_id = order_line.book_id WHERE book.title = 'The Little House'
Database: books
Question: Please list the titles of all the books that Lucas Wyldbore 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 = 'Lucas' AND customer.last_name = 'Wyldbore'
Database: books
Note: books have over 300 pages refers to num_pages > 300;
Question: Among the books ordered by Lucas Wyldbore, how many of them are over 300 pages?
SQL: SELECT count(*) 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 = 'Lucas' AND customer.last_name = 'Wyldbore' AND book.num_pages > 300
Database: books
Note: total price refers to Sum(price);
Question: What is the total price of all the books ordered by Lucas Wyldbore?
SQL: SELECT sum(order_line.price) FROM order_line 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 = 'Lucas' AND customer.last_name = 'Wyldbore'
Database: books
Note: average spend on book orders = AVG (price);
Question: How much money on average does Lucas Wyldbore spend on book orders?
SQL: SELECT sum(order_line.price) / count(*) FROM order_line 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 = 'Lucas' AND customer.last_name = 'Wyldbore'
Database: books
Note: books over $13 refers to price > 13; percentage = Divide (Sum (order_id where price > 13), Count (order_id)) * 100;
Question: Among the books ordered by Lucas Wyldbore, what is the percentage of those books over $13?
SQL: SELECT cast(sum(CASE WHEN order_line.price > 13 THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) FROM order_line 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 = 'Lucas' AND customer.last_name = 'Wyldbore'
Database: books
Question: Which city does the address id 547 belong to?
SQL: SELECT city FROM address WHERE address_id = 547
Database: books
Question: How many orders has Cordy Dumbarton made?
SQL: SELECT count(*) FROM customer INNER JOIN cust_order ON customer.customer_id = cust_order.customer_id WHERE customer.first_name = 'Cordy' AND customer.last_name = 'Dumbarton'
Database: books
Note: Japanese book refers to language_name = 'Japanese'; earliest published refers to Min(publication_date);
Question: List the title of the earliest published Japanese book.
SQL: SELECT book.title FROM book INNER JOIN book_language ON book.language_id = book_language.language_id WHERE book_language.language_name = 'Japanese' ORDER BY book.publication_date ASC LIMIT 1
Database: books
Note: published the most books refers to Max(Count(book_id)); publisher refers to publisher_name;
Question: For the publisher which published the most books, show its name.
SQL: SELECT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id GROUP BY publisher.publisher_name ORDER BY count(publisher.publisher_id) DESC LIMIT 1
Database: books
Note: "Kensington" is the publisher_name;
Question: How many books were published by Kensington?
SQL: SELECT count(book.book_id) FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE publisher.publisher_name = 'Kensington'
Database: books
Note: language written in refers to language_name;
Question: Which language was book id 1405 written in?
SQL: SELECT book_language.language_name FROM book INNER JOIN book_language ON book.language_id = book_language.language_id WHERE book.book_id = 1405
Database: books
Note: most order refers to Max(Count(order_id)); customer refers to first_name, last_name;
Question: Which customer has made the most orders? Show his/her full name.
SQL: SELECT customer.first_name, customer.last_name FROM customer INNER JOIN cust_order ON customer.customer_id = cust_order.customer_id GROUP BY customer.first_name, customer.last_name ORDER BY count(*) DESC LIMIT 1
Database: books
Note: book title refers to title; best sellers refers to title where Max(count(order_id));
Question: Name the book title of the bestseller.
SQL: SELECT book.title FROM book INNER JOIN order_line ON book.book_id = order_line.book_id GROUP BY book.title ORDER BY count(book.title) DESC LIMIT 1
Database: books
Note: "David Foster Wallace" is the author_name;
Question: How many books did David Foster Wallace write?
SQL: SELECT count(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 = 'David Foster Wallace'
Database: books
Note: "O Xará" is the title of the book;
Question: How many orders does the book "O Xará" have?
SQL: SELECT count(*) FROM book INNER JOIN order_line ON book.book_id = order_line.book_id WHERE book.title = 'O Xará'
Database: books
Note: country refers to country_name;
Question: Which country does Malina Johnson live in?
SQL: SELECT country.country_name FROM customer INNER JOIN customer_address ON customer.customer_id = customer_address.customer_id INNER JOIN address ON address.address_id = customer_address.address_id INNER JOIN country ON country.country_id = address.country_id WHERE customer.first_name = 'Malina' AND customer.last_name = 'Johnson' AND customer_address.status_id = 2
Database: books
Note: Ukrainian address refers to country_name = 'Ukraine';
Question: Give the number of Ukrainian addresses in the database.
SQL: SELECT count(*) FROM country INNER JOIN address ON country.country_id = address.country_id WHERE country.country_name = 'Ukraine'
Database: books
Note: "Žirovnica" is the city; country refers to country_name;
Question: Which country does Žirovnica city belong to?
SQL: SELECT country.country_name FROM country INNER JOIN address ON country.country_id = address.country_id WHERE address.city = 'Žirovnica'
Database: books
Note: International shipping order refers to method_name = 'International'; orders on 2022/11/10 refers to order_date LIKE '2022-11-10%'; percentage = Divide (Sum(order_id  where method_name = 'International'), Count(order_id)) * 100;
Question: Calculate the percentage of the International shipping orders on 2022/11/10.
SQL: SELECT cast(sum(CASE WHEN shipping_method.method_name = 'International' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) FROM shipping_method INNER JOIN cust_order ON shipping_method.method_id = cust_order.shipping_method_id WHERE cust_order.order_date LIKE '2022-11-10%'
Database: books
Note: number of pages refers to num_pages; average = Divide (Sum(num_pages), Count(book_id));
Question: What is the average number of pages of David Coward's books?
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 = 'David Coward'
Database: books
Note: slowest and least expesive method refers to shipping_method = 'Standard';
Question: What is the cost of the slowest and least expensive shipping method?
SQL: SELECT method_name FROM shipping_method ORDER BY cost ASC LIMIT 1
Database: books
Note: published in 1900 refers to publication_date LIKE '1900%'; first book refers to Min(publication_date);
Question: What is the title of the first book that was published in 1900?
SQL: SELECT title FROM book WHERE strftime('%Y', publication_date) = '1900' ORDER BY publication_date LIMIT 1
Database: books
Note: "aalleburtonkc@yellowbook.com" is the email of customer; full name refers to first_name, last_name;
Question: What is the full name of the customer who owns the "aalleburtonkc@yellowbook.com" e-mail address?
SQL: SELECT first_name, last_name FROM customer WHERE email = 'aalleburtonkc@yellowbook.com'
Database: books
Note: Iran as their destination refers to country_name = 'Iran'; orders in 2022 refers to order_date LIKE '2022%';
Question: How many orders in 2022 have Iran as their destinations?
SQL: SELECT count(*) FROM country INNER JOIN address ON country.country_id = address.country_id INNER JOIN cust_order ON cust_order.dest_address_id = address.address_id WHERE country.country_name = 'Iran' AND strftime('%Y', cust_order.order_date) = '2022'
Database: books
Note: via international shipping refers to method_name = 'International';
Question: Among Daisey Lamball's orders, how many were shipped via International shipping?
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 = 'Daisey' AND customer.last_name = 'Lamball' AND shipping_method.method_name = 'International'
Database: books
Note: customer who ordered the most book refers to customer_id where Max(count(order_id)); full name refers to first_name, last_name;
Question: What is the full name of the customer who ordered the most books of all time?
SQL: SELECT customer.first_name, customer.last_name FROM customer INNER JOIN cust_order ON customer.customer_id = cust_order.customer_id GROUP BY customer.first_name, customer.last_name ORDER BY count(*) DESC LIMIT 1
Database: books
Note: order returned refers to status_value = 'Returned';
Question: How many orders did Antonia Poltun return?
SQL: SELECT count(*) 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 INNER JOIN customer ON customer.customer_id = cust_order.customer_id WHERE order_status.status_value = 'Returned' AND customer.first_name = 'Antonia' AND customer.last_name = 'Poltun'
Database: books
Note: shipping method preferred the most by customers refers to method_id where Max(Count(method_id)); which shipping method refers to method_name;
Question: Which shipping method is preferred by customers the most?
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) DESC LIMIT 1
Database: books
Note: delivered refers to status_value = 'Delivered'; in 2021 refers to status_date LIKE '2021%';
Question: How many orders were delivered in 2021?
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) = '2021'
Database: books
Note: "J.K Rowling" is the author_name; first published book refers to book_id where Min(publication_date); name of the book refers to title;
Question: What is the name of the first book written by J.K Rowling?
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 = 'J.K. Rowling' ORDER BY book.publication_date ASC LIMIT 1
Database: books
Note: "A.R. Braunmuller" is the author_name;
Question: How many books did A.R. Braunmuller write?
SQL: SELECT count(*) FROM author INNER JOIN book_author ON author.author_id = book_author.author_id WHERE author.author_name = 'A.R. Braunmuller'
Database: books
Note: "Agatha Christie" is the author_name; name of publisher refers to publisher_name; first book refers to Min(publication_date);
Question: What is the name of the publisher who published Agatha Christie's first 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 = 'Agatha Christie' ORDER BY book.publication_date ASC LIMIT 1
Database: books
Note: "Danielle Steel" is the author_name; name of books refers to title;
Question: List all the names of the books written by Danielle Steel.
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 = 'Danielle Steel'
Database: books
Note: "William Shakespeare" is the author_name; "Penguin Classics" is the publisher_name;
Question: How many books by William Shakespeare were published by Penguin Classics?
SQL: SELECT count(*) 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 = 'William Shakespeare' AND publisher.publisher_name = 'Penguin Classics'
Database: books
Note: name of publisher refers to publisher_name; publisher published the most number of books refers to Max(Count(book_id));
Question: What is the name of the publisher that published the most books?
SQL: SELECT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id GROUP BY publisher.publisher_name ORDER BY count(publisher.publisher_id) DESC LIMIT 1
Database: books
Note: shipping cost refers to cost; ordered in 2022 refers to order_date LIKE '2022%';
Question: What is the total shipping cost of all the orders made by Page Holsey? Indicate how many of the said orders were ordered in 2022.
SQL: SELECT sum(shipping_method.cost) 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 = 'Page' AND customer.last_name = 'Holsey' AND strftime('%Y', cust_order.order_date) = '2022'
Database: books
Note: name of publisher refers to publisher_name;
Question: What is the name of the publisher with publisher ID 22?
SQL: SELECT publisher_name FROM publisher WHERE publisher_id = 22
Database: books
Note: "AI Gore" is the author_name; have less than 400 pages refers to num_pages < 400;
Question: How many of the books authored by Al Gore have less than 400 pages?
SQL: SELECT count(*) 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 = 'Al Gore' AND book.num_pages < 400
Database: books
Note: author's name refers to author_name; publisher's name refers to publisher_name; book published on July 10, 1997 refers to publication_date LIKE '1997-07-10';
Question: List the author's and publisher's name of the book published on July 10, 1997.
SQL: SELECT author.author_name, 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 book.publication_date = '1997-07-10'
Database: books
Note: "23755004321" is the isbn13; language refers to language_name;
Question: What is the language of the book with ISBN 23755004321?
SQL: SELECT book_language.language_name FROM book INNER JOIN book_language ON book.language_id = book_language.language_id WHERE book.isbn13 = 23755004321
Database: books
Note: most expensive book refers to Max(price);
Question: What is the title of the most expensive book?
SQL: SELECT book.title FROM book INNER JOIN order_line ON book.book_id = order_line.book_id ORDER BY order_line.price DESC LIMIT 1
Database: books
Note: total price refers to Sum(price); full name is composed of first name, last name;
Question: Calculate the total price of books ordered by customer named Lucas Wyldbore.
SQL: SELECT sum(order_line.price) FROM order_line 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 = 'Lucas' AND customer.last_name = 'Wyldbore'
Database: books
Note: "Spanish" is the language_name; ISBN refers to isbn13;
Question: List the ISBN of the book published in Spanish.
SQL: SELECT book.isbn13 FROM book INNER JOIN book_language ON book.language_id = book_language.language_id WHERE book_language.language_name = 'Spanish'
Database: books
Note: book cost less than 1 dollar refers to price < 1; 'Berkley Trade' is the publisher_name;
Question: Among the books that cost less than 1 dollar, how many were published by Berkley Trade?
SQL: SELECT count(*) FROM publisher INNER JOIN book ON publisher.publisher_id = book.publisher_id INNER JOIN order_line ON order_line.book_id = book.book_id WHERE publisher.publisher_name = 'Berkley' AND order_line.price < 1
Database: books
Question: List the title of the books purchased by the customer named Zia Roizin.
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 = 'Zia' AND customer.last_name = 'Roizin'
Database: books
Note: greatest number of pages refers to Max(num_pages); who authored refers to author_name;
Question: Who authored the book with greatest number of pages?
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
Database: books
Note: "Switch on the Night" is the title;
Question: List the email of customers that bought the book titled Switch on the Night.
SQL: SELECT customer.email 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 = 'Switch on the Night'
Database: books
Note: "Abrams" is the publisher_name; author's name refers to author_name;
Question: List the author's name of the books published by Abrams.
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 INNER JOIN publisher ON publisher.publisher_id = book.publisher_id WHERE publisher.publisher_name = 'Abrams'
Database: books
Note: "The Illuminati" is the title of book;
Question: What is the publisher name of the book titled The Illuminati?
SQL: SELECT publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE book.title = 'The Illuminati'
Database: books
Note: "Abraham Lincoln" is the author_name; published in 1992 refers to publication_date LIKE '1992%'; percentage = Divide (Sum(publication_date LIKE '1992%'), Count(publication_date)) * 100;
Question: In books authored by Abraham Lincoln, what is the percentage of the books published in 1992?
SQL: SELECT cast(sum(CASE WHEN strftime('%Y', book.publication_date) = '1992' THEN 1 ELSE 0 END) AS REAL) * 100 / count(*) 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 = 'Abraham Lincoln'
Database: books
Note: published in 2004 refers to publication_date LIKE '2004%'; books with number of pages greater than 70% of the average number of pages refers to num_pages > Multiply(Avg(num_pages), 0.7); name of publisher refers to publisher_name;
Question: Among the books published in 2004, list the name of the publisher of books with number of pages greater than 70% of the average number of pages of all books.
SQL: SELECT book.title, publisher.publisher_name FROM book INNER JOIN publisher ON book.publisher_id = publisher.publisher_id WHERE strftime('%Y', book.publication_date) = '2004' AND book.num_pages * 100 > ( SELECT avg(num_pages) FROM book ) * 70
Database: books
Question: Provide the contact email of Moss Zarb.
SQL: SELECT email FROM customer WHERE first_name = 'Moss' AND last_name = 'Zarb'
Database: books
Note: "Dallas" is the city; streets refers to street_name;
Question: Name the streets in Dallas.
SQL: SELECT street_name FROM address WHERE city = 'Dallas'
Database: books
Note: "Orson Scott Card" is the author_name; released in 2001 refers to publication_date LIKE '2001%'; books refers to title;
Question: Which books were released by Orson Scott Card in 2001?
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 = 'Orson Scott Card' AND strftime('%Y', book.publication_date) = '2001'
Database: books
Note: "Orson Scott Card" is the author_name;
Question: Count the number of books written by Orson Scott Card.
SQL: SELECT count(*) 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 = 'Orson Scott Card'
Database: books
Note: authors refers to author_name; more than 3000 pages refers to num_pages > 3000;
Question: Provide the authors and titles of the books which have more than 3000 pages.
SQL: SELECT author.author_name, 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 book.num_pages > 3000
Database: books
Note: "The Prophet" is the title of the book: who wrote refers to author_name;
Question: Who wrote "The Prophet"?
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.title = 'The Prophet'