1sf/bird-sql-train-with-schema huggingface dataset:
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: List all the titles and year to date sales by author who are not on contract.
Evidence: year to date sales refers to ytd_sales; not on contract refers to contract = 0
SQL: SELECT T1.title_id, T1.ytd_sales FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: For all authors from CA who are not on contract, which title of his/hers has the most year to date sales.
Evidence: year to date sales refers to ytd_sales; on contract refers to contract = 1
SQL: SELECT T1.title FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T3.contract = 0 AND T3.state = 'CA' ORDER BY T1.ytd_sales DESC LIMIT 1
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Name all the authors for 'Sushi, Anyone?'.
Evidence: most year to date sales refers to MAX(ytd_sales); on contract refers to contract = 1; name of author = au_fname, au_lname
SQL: SELECT T3.au_fname, T3.au_lname FROM titles AS T1 INNER JOIN titleauthor AS T2 ON T1.title_id = T2.title_id INNER JOIN authors AS T3 ON T2.au_id = T3.au_id WHERE T1.title = 'Sushi, Anyone?'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Calculate the percentage of the employees who are Editor or Designer?
Evidence: 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
SQL: SELECT CAST(SUM(CASE WHEN T2.job_desc IN ('Editor', 'Designer') THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: List all titles which have year to date sales higher than the average order by pubisher name.
Evidence: year to date sales refers to ytd_sales; average order = AVG(ytd_sales)
SQL: SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.ytd_sales > ( SELECT AVG(ytd_sales) FROM titles )
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: How many publishers are in the USA?
SQL: SELECT COUNT(pub_id) FROM publishers WHERE country = 'USA'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: What is the publisher's information of New Moon Books?
Evidence: publisher name refers to pub_name; New Moon Books is a publisher name
SQL: SELECT T1.pr_info FROM pub_info AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Please list the first names of the employees who work as Managing Editor.
Evidence: Managing Editor is a job description which refers to job_desc
SQL: SELECT T1.fname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T2.job_desc = 'Managing Editor'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: What is the highest level of job to get to for the employee who got hired the earliest?
Evidence: highest job level refers to MAX(job_lvl); hired the earliest refers to MIN(hire_date)
SQL: SELECT T2.max_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.hire_date LIMIT 1
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: In which city is the store with the highest total sales quantity located?
Evidence: qty is abbreviation for quantity; highest sales quantity refers to MAX(qty)
SQL: SELECT T2.city FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id GROUP BY T2.city ORDER BY SUM(T1.qty) DESC LIMIT 1
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: What is the price of the book that sells the best?
Evidence: qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)
SQL: SELECT T2.price FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id ORDER BY T1.qty DESC LIMIT 1
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Please list the stores that ordered the book "Life Without Fear".
Evidence: store name refers to stor_name
SQL: SELECT T2.stor_name FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T3.title = 'Life Without Fear'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Among the stores that have ordered the book "Life Without Fear", how many of them are located in Massachusetts?
Evidence: Massachusetts is a state
SQL: SELECT COUNT(T1.stor_id) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: In which country is the publisher of the book "Life Without Fear" located?
Evidence: Life Without Fear is book title
SQL: SELECT T2.country FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Life Without Fear'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: What is the publisher that has published the most expensive book?
Evidence: most expensive book refers to MAX(price)
SQL: SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T1.price DESC LIMIT 1
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Among the publishers in the USA, how many of them have published books that are over $15?
Evidence: are over $15 refers to price>15
SQL: SELECT COUNT(DISTINCT T1.pub_id) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'USA' AND T1.price > 15
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Please give more detailed information about the first three books that sell the best.
Evidence: qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)
SQL: SELECT T1.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id ORDER BY T2.qty DESC LIMIT 3
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: How many books on business have the bookstores in Massachusetts ordered?
Evidence: Massachusetts is a state; business books refers to type = 'business'
SQL: SELECT SUM(T1.qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts' AND T3.type = 'business'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: What is the average quantity of each order for the book "Life Without Fear"?
Evidence: qty is abbreviation for quantity; average quantity order = AVG(qty)
SQL: SELECT CAST(SUM(T2.qty) AS REAL) / COUNT(T1.title_id) FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE T1.title = 'Life Without Fear'