Chinastark/bird_dataset huggingface dataset:
Database: book_publishing_company
Note: total quantity refers to qty; most ordered quantity refers to order with the highest quantity where MAX(count(qty)); date refers to ord_date; year 1992 refers to YEAR(ord_date) = 1992;
Question: What is the title with the most ordered quantity in year 1992?
SQL: SELECT titles.title FROM sales INNER JOIN titles ON sales.title_id = titles.title_id WHERE strftime('%Y', sales.ord_date) = '1992' ORDER BY sales.qty DESC LIMIT 1
Database: book_publishing_company
Note: publication date refers to pubdate; payment terms refers to payterms; payterms = 'ON invoice';
Question: List the title, price and publication date for all sales with 'ON invoice' payment terms.
SQL: SELECT titles.title, titles.price, titles.pubdate FROM sales INNER JOIN titles ON sales.title_id = titles.title_id WHERE sales.payterms = 'ON invoice'
Database: book_publishing_company
Note: at least 10% royalty refers to royalty >= 10; minimum range is synonym for low range which refers to lorange; without minimum range amount refers to lorange <> 0;
Question: What is the title that have at least 10% royalty without minimum range amount.
SQL: SELECT titles.title FROM titles INNER JOIN roysched ON titles.title_id = roysched.title_id WHERE roysched.lorange = 0 AND roysched.royalty >= 10
Database: book_publishing_company
Note: lorange mean low range; hirange mean high range; range refers to between the low and high range; lorange>10000; hirange<12000;
Question: State the title and royalty percentage for title ID BU2075 between 10000 to 50000 range.
SQL: SELECT titles.title, roysched.royalty FROM titles INNER JOIN roysched ON titles.title_id = roysched.title_id WHERE roysched.lorange > 10000 AND roysched.hirange < 50000 AND titles.title_id = 'BU2075'
Database: book_publishing_company
Note: minimum range is synonym for low range which refers to lorange;
Question: Among the titles with royalty percentage, which title has the greatest royalty percentage. State it's minimum range to enjoy this royalty percentage.
SQL: SELECT titles.title, roysched.lorange FROM titles INNER JOIN roysched ON titles.title_id = roysched.title_id ORDER BY roysched.royalty DESC LIMIT 1
Database: book_publishing_company
Note: publisher name refers to pub_name;
Question: Provide a list of titles together with its publisher name for all publishers located in the USA.
SQL: SELECT titles.title, publishers.pub_name FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE publishers.country = 'USA'
Database: book_publishing_company
Note: most year to date sales refers to MAX(ytd_sales); range limit means high range which refers to hirange; the 20000 range refers to hirange<20000;
Question: State the royalty percentage for the most year to date sale title within the 20000 range.
SQL: SELECT max(titles.ytd_sales) FROM titles INNER JOIN roysched ON titles.title_id = roysched.title_id WHERE roysched.lorange > 20000 AND roysched.hirange < 20000
Database: book_publishing_company
Note: publisher name refers to pub_name; publication date refers to pubdate; published in year 1991 refers to YEAR(pubdate) = 1991;
Question: List all titles published in year 1991. Also provide notes details of the title and the publisher's name.
SQL: SELECT titles.title, titles.notes, publishers.pub_name FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE strftime('%Y', titles.pubdate) = '1991'
Database: book_publishing_company
Note: qty is abbreviation for quantity; sales of quantity more than 20 refers to qty>20; store refers to stor_name;
Question: List all titles with sales of quantity more than 20 and store located in the CA state.
SQL: SELECT titles.title, sales.qty FROM titles INNER JOIN sales ON titles.title_id = sales.title_id INNER JOIN stores ON sales.stor_id = stores.stor_id WHERE sales.qty > 20 AND stores.state = 'CA'
Database: book_publishing_company
Note: qty is abbreviation for quantity; highest quantity refers to MAX(qty); least quantity refers to MIN(qty);
Question: Name the store with the highest quantity in sales? What is the least quantity title from the store's sale?
SQL: SELECT stores.stor_id, titles.title FROM sales INNER JOIN titles ON sales.title_id = titles.title_id INNER JOIN stores ON stores.stor_id = sales.stor_id WHERE stores.stor_id = ( SELECT stor_id FROM sales GROUP BY stor_id ORDER BY sum(qty) DESC LIMIT 1 ) GROUP BY stores.stor_id, titles.title ORDER BY sum(sales.qty) ASC LIMIT 1
Database: book_publishing_company
Note: name the publisher refers to pub_name;
Question: Name the title and publisher for title ID BU 2075. Provide all the royalty percentage for all ranges.
SQL: SELECT titles.title, publishers.pub_name, roysched.lorange, roysched.hirange, roysched.royalty FROM titles INNER JOIN roysched ON titles.title_id = roysched.title_id INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.title_id = 'BU2075'
Database: book_publishing_company
Note: store with ID 7066 refers to stor_id = '7066'; 'Net 60' payment terms refers to payterm = 'Net 60'; qty is abbreviation for quantity; percentage = DIVIDE(payterms = 'Net 60', sum(qty))*100;
Question: Name the store with ID 7066 and calculate the percentage of the the quantity ordered that were on 'Net 30' payment terms.
SQL: SELECT stores.stor_name , cast(sum(CASE WHEN payterms = 'Net 30' THEN qty ELSE 0 END) AS REAL) * 100 / sum(qty) FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id WHERE sales.stor_id = '7066' GROUP BY stores.stor_name
Database: book_publishing_company
Note: publisher id refers to pub_id; publisher name refers to pub_name; average year to date sales = AVG(ytd_sales);
Question: State the publisher name for publisher ID 877? Calculate its average year to date sales.
SQL: SELECT publishers.pub_name, avg(titles.ytd_sales) FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.pub_id = '0877' GROUP BY publishers.pub_name
Database: book_publishing_company
Note: hired before year 1990 refers to YEAR(hire_date)<1990;
Question: Name all employees who were hired before year 1990.
SQL: SELECT fname, lname FROM employee WHERE strftime('%Y', hire_date) < '1990'
Database: book_publishing_company
Note: lowest job level refers to MIN(job_lvl);
Question: Which employee has the lowest job level. State the first name, last name and when he /she was hired.
SQL: SELECT fname, lname, hire_date FROM employee ORDER BY job_lvl LIMIT 1
Database: book_publishing_company
Note: most hired employees refers to MAX(count(emp_id));
Question: In which year has the most hired employees?
SQL: SELECT strftime('%Y', hire_date) FROM employee GROUP BY strftime('%Y', hire_date) ORDER BY count(emp_id) DESC LIMIT 1
Database: book_publishing_company
Note: maximum level in their job designation refers to job_lvl = MAX(max_lvl);
Question: List all employees who are at the maximum level in their job designation.
SQL: SELECT employee.fname, employee.lname FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE employee.job_lvl = jobs.max_lvl
Database: book_publishing_company
Note: Chief Financial Offer is a job description which refers to job_desc;
Question: Name the Chief Executive Officer and when he/she was hired.
SQL: SELECT employee.fname, employee.lname, employee.hire_date FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE jobs.job_desc = 'Chief Financial Officier'
Database: book_publishing_company
Note: not located at USA refers to country! = 'USA';
Question: Who are the employees working for publisher not located in USA? State the employee's name and publisher name.
SQL: SELECT employee.fname, employee.lname, publishers.pub_name FROM employee INNER JOIN publishers ON employee.pub_id = publishers.pub_id WHERE publishers.country != 'USA'
Database: book_publishing_company
Note: name = fname, lname; job description refers to job_desc; publisher refers pub_name;
Question: List all employees working for publisher 'GGG&G'. State their name and job description.
SQL: SELECT employee.fname, employee.lname, jobs.job_desc FROM employee INNER JOIN publishers ON employee.pub_id = publishers.pub_id INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE publishers.pub_name = 'GGG&G'
Database: book_publishing_company
Note: publisher name refers to pub_name;
Question: For each publisher, state the type of titles they published order by the publisher name.
SQL: SELECT DISTINCT publishers.pub_name, titles.type FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id ORDER BY publishers.pub_name
Database: book_publishing_company
Note: most title published refers to MAX(count(title_id); published in 1991 refers to YEAR(pubdate) = 1991;
Question: Name the publisher which has the most titles published in 1991.
SQL: SELECT publishers.pub_name FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE strftime('%Y', titles.pubdate) = '1991' GROUP BY titles.pub_id, publishers.pub_name ORDER BY count(titles.title_id) DESC LIMIT 1
Database: book_publishing_company
Note: published by refers to pub_name;
Question: Name the title with the highest price published by 'Binnet & Hardley'.
SQL: SELECT titles.title FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE publishers.pub_name = 'Binnet & Hardley' ORDER BY titles.price DESC LIMIT 1
Database: book_publishing_company
Note: job level greater than 200 refers to job_lvl>200; job description refers to job_desc;
Question: Among all employees, who have job level greater than 200. State the employee name and job description.
SQL: SELECT employee.fname, employee.lname, jobs.job_desc FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE employee.job_lvl > 200
Database: book_publishing_company
Note: business title refers to title under business where type = 'business';
Question: Name all the authors for all business titles.
SQL: SELECT authors.au_fname, authors.au_lname FROM titles INNER JOIN titleauthor ON titles.title_id = titleauthor.title_id INNER JOIN authors ON titleauthor.au_id = authors.au_id WHERE titles.type = 'business'
Database: book_publishing_company
Note: year to date sales refers to ytd_sales; not on contract refers to contract = 0;
Question: List all the titles and year to date sales by author who are not on contract.
SQL: SELECT titles.title_id, titles.ytd_sales FROM titles INNER JOIN titleauthor ON titles.title_id = titleauthor.title_id INNER JOIN authors ON titleauthor.au_id = authors.au_id WHERE authors.contract = 0
Database: book_publishing_company
Note: year to date sales refers to ytd_sales; on contract refers to contract = 1;
Question: For all authors from CA who are not on contract, which title of his/hers has the most year to date sales.
SQL: SELECT titles.title FROM titles INNER JOIN titleauthor ON titles.title_id = titleauthor.title_id INNER JOIN authors ON titleauthor.au_id = authors.au_id WHERE authors.contract = 0 AND authors.state = 'CA' ORDER BY titles.ytd_sales DESC LIMIT 1
Database: book_publishing_company
Note: most year to date sales refers to MAX(ytd_sales); on contract refers to contract = 1; name of author = au_fname, au_lname;
Question: Name all the authors for 'Sushi, Anyone?'.
SQL: SELECT authors.au_fname, authors.au_lname FROM titles INNER JOIN titleauthor ON titles.title_id = titleauthor.title_id INNER JOIN authors ON titleauthor.au_id = authors.au_id WHERE titles.title = 'Sushi, Anyone?'
Database: book_publishing_company
Note: Editor or Auditor are job description which refers to job_desc; percentage = DIVIDE(count(job_desc = 'Editor' or job_desc = 'Auditor'), count(emp_id))*100;
Question: Calculate the percentage of the employees who are Editor or Designer?
SQL: SELECT cast(sum(CASE WHEN jobs.job_desc IN ('Editor', 'Designer') THEN 1 ELSE 0 END) AS REAL) * 100 / count(employee.job_id) FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id
Database: book_publishing_company
Note: year to date sales refers to ytd_sales; average order = AVG(ytd_sales);
Question: List all titles which have year to date sales higher than the average order by pubisher name.
SQL: SELECT titles.title FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.ytd_sales > ( SELECT avg(ytd_sales) FROM titles )
Database: book_publishing_company
Question: How many publishers are in the USA?
SQL: SELECT count(pub_id) FROM publishers WHERE country = 'USA'
Database: book_publishing_company
Note: publisher name refers to pub_name; New Moon Books is a publisher name;
Question: What is the publisher's information of New Moon Books?
SQL: SELECT pub_info.pr_info FROM pub_info INNER JOIN publishers ON pub_info.pub_id = publishers.pub_id WHERE publishers.pub_name = 'New Moon Books'
Database: book_publishing_company
Note: Managing Editor is a job description which refers to job_desc;
Question: Please list the first names of the employees who work as Managing Editor.
SQL: SELECT employee.fname FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE jobs.job_desc = 'Managing Editor'
Database: book_publishing_company
Note: highest job level refers to MAX(job_lvl); hired the earliest refers to MIN(hire_date);
Question: What is the highest level of job to get to for the employee who got hired the earliest?
SQL: SELECT jobs.max_lvl FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id ORDER BY employee.hire_date LIMIT 1
Database: book_publishing_company
Note: qty is abbreviation for quantity; highest sales quantity refers to MAX(qty);
Question: In which city is the store with the highest total sales quantity located?
SQL: SELECT stores.city FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id GROUP BY stores.city ORDER BY sum(sales.qty) DESC LIMIT 1
Database: book_publishing_company
Note: qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty);
Question: What is the price of the book that sells the best?
SQL: SELECT titles.price FROM sales INNER JOIN titles ON sales.title_id = titles.title_id ORDER BY sales.qty DESC LIMIT 1
Database: book_publishing_company
Note: store name refers to stor_name;
Question: Please list the stores that ordered the book "Life Without Fear".
SQL: SELECT stores.stor_name FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id INNER JOIN titles ON sales.title_id = titles.title_id WHERE titles.title = 'Life Without Fear'
Database: book_publishing_company
Note: Massachusetts is a state;
Question: Among the stores that have ordered the book "Life Without Fear", how many of them are located in Massachusetts?
SQL: SELECT count(sales.stor_id) FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id INNER JOIN titles ON sales.title_id = titles.title_id WHERE stores.state = 'Massachusetts'
Database: book_publishing_company
Note: Life Without Fear is book title;
Question: In which country is the publisher of the book "Life Without Fear" located?
SQL: SELECT publishers.country FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.title = 'Life Without Fear'
Database: book_publishing_company
Note: most expensive book refers to MAX(price);
Question: What is the publisher that has published the most expensive book?
SQL: SELECT publishers.pub_name FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id ORDER BY titles.price DESC LIMIT 1
Database: book_publishing_company
Note: are over $15 refers to price>15;
Question: Among the publishers in the USA, how many of them have published books that are over $15?
SQL: SELECT count(DISTINCT titles.pub_id) FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE publishers.country = 'USA' AND titles.price > 15
Database: book_publishing_company
Note: qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty);
Question: Please give more detailed information about the first three books that sell the best.
SQL: SELECT titles.notes FROM titles INNER JOIN sales ON titles.title_id = sales.title_id ORDER BY sales.qty DESC LIMIT 3
Database: book_publishing_company
Note: Massachusetts is a state; business books refers to type = 'business';
Question: How many books on business have the bookstores in Massachusetts ordered?
SQL: SELECT sum(sales.qty) FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id INNER JOIN titles ON sales.title_id = titles.title_id WHERE stores.state = 'Massachusetts' AND titles.type = 'business'
Database: book_publishing_company
Note: qty is abbreviation for quantity; average quantity order = AVG(qty);
Question: What is the average quantity of each order for the book "Life Without Fear"?
SQL: SELECT cast(sum(sales.qty) AS REAL) / count(titles.title_id) FROM titles INNER JOIN sales ON titles.title_id = sales.title_id WHERE titles.title = 'Life Without Fear'
Database: book_publishing_company
Note: Managing Editor is a job description which refers to job_desc; job level refers to job_lvl; highest level job refers to max_lvl; levels between the average level and the highest level = SUBTRACT(max_lvl; AVG(job_lvl));
Question: What is the average level employees working as Managing Editor are at? How many levels are there between the average level and the highest level?
SQL: SELECT avg(employee.job_lvl), jobs.max_lvl - avg(employee.job_lvl) FROM jobs INNER JOIN employee ON jobs.job_id = employee.job_id WHERE jobs.job_desc = 'Managing Editor' GROUP BY employee.job_id, jobs.max_lvl
Database: book_publishing_company
Note: business books refers to type = 'business'; cheapest book refers to MIN(price);
Question: Which one is the cheapest business book?
SQL: SELECT title FROM titles WHERE TYPE = 'business' ORDER BY price LIMIT 1
Database: book_publishing_company
Note: most pre-paid amount refers to MAX(advance);
Question: Which type of book had the most pre-paid amount?
SQL: SELECT TYPE FROM titles ORDER BY advance DESC LIMIT 1
Database: book_publishing_company
Note: qty is abbreviation for quantity; bestseller means with the most sales quantity; MAX(qty);
Question: What's the royalty for the bestseller book?
SQL: SELECT royalty FROM titles ORDER BY ytd_sales DESC LIMIT 1
Database: book_publishing_company
Note: job level refers to job_lvl;
Question: Which job level is O'Rourke at?
SQL: SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'
Database: book_publishing_company
Note: highest employee refers to employee with the highest job level; MAX(job_lvl);
Question: Show me the employ id of the highest employee who doesn't have a middle name.
SQL: SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1
Database: book_publishing_company
Note: contract = 1 means on contract; contract = 0 means not on contract;
Question: Is the author of "Sushi, Anyone?" on the contract?
SQL: SELECT authors.contract FROM authors INNER JOIN titleauthor ON authors.au_id = titleauthor.au_id INNER JOIN titles ON titleauthor.title_id = titles.title_id WHERE titles.title = 'Sushi, Anyone?'
Database: book_publishing_company
Note: highest job level refers to MAX(job_lvl);
Question: Which publisher had the highest job level? Give his/her full name.
SQL: SELECT employee.fname, employee.minit, employee.lname FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id ORDER BY employee.job_lvl DESC LIMIT 1
Database: book_publishing_company
Note: job title means job description which refers to job_desc;
Question: What's Pedro S Afonso's job title?
SQL: SELECT jobs.job_desc FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE employee.fname = 'Pedro' AND employee.minit = 'S' AND employee.lname = 'Afonso'
Database: book_publishing_company
Note: max level for his position refers to max_lvl; job level refers to job_lvl; level left to reach the max = SUBTRACT(max_lvl, job_lvl);
Question: How many levels are there left for Diego W Roel to reach if he/she could go to the max level for his/her position?
SQL: SELECT jobs.max_lvl - employee.job_lvl FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE employee.fname = 'Diego' AND employee.minit = 'W' AND employee.lname = 'Roel'
Database: book_publishing_company
Note: order happened on refers to ord_date;
Question: What's on the notes for the order happened on 1994/9/14?
SQL: SELECT titles.notes FROM titles INNER JOIN sales ON titles.title_id = sales.title_id WHERE strftime('%Y-%m-%d', sales.ord_date) = '1994-09-14'
Database: book_publishing_company
Note: sold on refers to ord_date;
Question: List the type of the book for the order which was sold on 1993/5/29.
SQL: SELECT DISTINCT titles.type FROM titles INNER JOIN sales ON titles.title_id = sales.title_id WHERE strftime('%Y-%m-%d', sales.ord_date) = '1993-05-29'
Database: book_publishing_company
Note: French publisher means publisher in France where country = 'France';
Question: Tell me about the information of the French publisher.
SQL: SELECT pub_info.pr_info FROM pub_info INNER JOIN publishers ON pub_info.pub_id = publishers.pub_id WHERE publishers.country = 'France'
Database: book_publishing_company
Note: publisher name refers to pub_name; Silicon Valley Gastronomic Treats is the title of a book;
Question: What's the publisher of the book "Silicon Valley Gastronomic Treats"? Give the publisher's name.
SQL: SELECT publishers.pub_name FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.title = 'Silicon Valley Gastronomic Treats'
Database: book_publishing_company
Question: Which city did Victoria P Ashworth work in?
SQL: SELECT publishers.city FROM employee INNER JOIN publishers ON employee.pub_id = publishers.pub_id WHERE employee.fname = 'Victoria' AND employee.minit = 'P' AND employee.lname = 'Ashworth'
Database: book_publishing_company
Note: Remulade is a city; sales in the store refers to ord_num;
Question: How many sales did the store in Remulade make?
SQL: SELECT count(sales.ord_num) FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id WHERE stores.city = 'Remulade'
Database: book_publishing_company
Note: qty is abbreviation for quantity; Fremont and Portland are name of city; sell in 1993 refers to YEAR(ord_date) = 1993; percentage = DIVIDE( SUBTRACT(SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)),  SUM(qty where city = ‘Portland’ and year(ord_date = 1993))), SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)) *100;
Question: For the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993?
SQL: SELECT cast(sum(CASE WHEN stores.city = 'Fremont' THEN qty END) - sum(CASE WHEN stores.city = 'Portland' THEN qty END) AS REAL) * 100 / sum(CASE WHEN stores.city = 'Fremont' THEN qty END) FROM sales INNER JOIN stores ON sales.stor_id = stores.stor_id WHERE strftime('%Y', sales.ord_date) = '1993'
Database: book_publishing_company
Note: publisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer'));
Question: Among all the employees, how many percent more for the publishers than designers?
SQL: SELECT cast(sum(CASE WHEN jobs.job_desc = 'publisher' THEN 1 ELSE 0 END) - sum(CASE WHEN jobs.job_desc = 'designer' THEN 1 ELSE 0 END) AS REAL) * 100 / count(employee.job_id) FROM employee INNER JOIN jobs ON employee.job_id = jobs.job_id
Database: book_publishing_company
Note: job level refers to job_lvl; YEAR(hire_date) between 1990 and 1995;
Question: Find and list the full name of employees who were hired between 1990 and 1995. Also, arrange them in the descending order of job level.
SQL: SELECT fname, minit, lname FROM employee WHERE strftime('%Y', hire_date) BETWEEN '1990' AND '1995' ORDER BY job_lvl DESC
Database: book_publishing_company
Note: average royalty rate = DIVIDE(SUM(royalty), COUNT(title_id));
Question: Which titles has above average royalty rate? Give those title's name, type and price?
SQL: SELECT DISTINCT titles.title, titles.type, titles.price FROM titles INNER JOIN roysched ON titles.title_id = roysched.title_id WHERE roysched.royalty > ( SELECT cast(sum(royalty) AS REAL) / count(title_id) FROM roysched )