question
stringlengths
24
325
sql
stringlengths
30
804
db_id
stringclasses
63 values
question_id
int64
167
9.43k
difficulty
stringclasses
1 value
table_names_with_rag
stringlengths
18
220
create_statements_all
sequencelengths
1
1
create_statements_rag
sequencelengths
1
1
len_create_all
int64
2
65
len_create_rag
int64
2
65
column_names_with_rag
stringlengths
139
1.24k
Which date has the most ordered quantity? What is the total order quantity on that day?
SELECT ord_date, SUM(qty) FROM sales GROUP BY ord_date ORDER BY SUM(qty) DESC LIMIT 1
book_publishing_company
167
["stores", "titles", "employee", "jobs", "roysched", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"sales\": [\"ord_date\", \"qty\", \"ord_num\", \"payterms\", \"stor_id\", \"title_id\"], \"employee\": [\"hire_date\", \"minit\", \"job_id\", \"emp_id\", \"job_lvl\"], \"titles\": [\"pubdate\", \"price\", \"ytd_sales\", \"advance\", \"title_id\", \"pub_id\", \"type\", \"title\"], \"discounts\": [\"discount\", \"discounttype\", \"highqty\", \"stor_id\", \"lowqty\"], \"stores\": [\"city\", \"state\", \"stor_id\", \"stor_name\", \"zip\", \"stor_address\"]}"
What is the title with the most ordered quantity in year 1992?
SELECT T2.title FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y', T1.ord_date) = '1992' ORDER BY T1.qty DESC LIMIT 1
book_publishing_company
168
["stores", "titles", "roysched", "sales", "discounts", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"advance\", \"type\", \"title\", \"ytd_sales\", \"title_id\", \"royalty\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"title_id\", \"au_id\", \"au_ord\", \"royaltyper\"], \"roysched\": [\"title_id\", \"royalty\", \"lorange\", \"hirange\"], \"sales\": [\"title_id\", \"ord_date\", \"qty\"], \"discounts\": [\"discount\", \"discounttype\", \"stor_id\", \"highqty\", \"lowqty\"]}"
List the title, price and publication date for all sales with 'ON invoice' payment terms.
SELECT T2.title, T2.price, T2.pubdate FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id WHERE T1.payterms = 'ON invoice'
book_publishing_company
169
["stores", "titles", "employee", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"ytd_sales\", \"pubdate\", \"title_id\", \"type\", \"title\", \"advance\", \"notes\", \"royalty\", \"pub_id\"], \"sales\": [\"ord_date\", \"title_id\", \"payterms\", \"qty\", \"stor_id\", \"ord_num\"], \"employee\": [\"hire_date\"], \"titleauthor\": [\"title_id\", \"royaltyper\", \"au_ord\", \"au_id\"], \"discounts\": [\"discount\", \"discounttype\", \"highqty\", \"stor_id\", \"lowqty\"]}"
What is the title that have at least 10% royalty without minimum range amount.
SELECT T1.title FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.lorange = 0 AND T2.royalty >= 10
book_publishing_company
170
["stores", "titles", "roysched", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"title\", \"title_id\", \"price\", \"type\", \"advance\", \"ytd_sales\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_id\", \"au_ord\"], \"roysched\": [\"royalty\", \"title_id\", \"lorange\", \"hirange\"], \"sales\": [\"title_id\", \"payterms\", \"ord_num\", \"qty\", \"stor_id\", \"ord_date\"], \"discounts\": [\"lowqty\", \"discount\", \"discounttype\", \"stor_id\"]}"
State the title and royalty percentage for title ID BU2075 between 10000 to 50000 range.
SELECT T1.title, T2.royalty FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.lorange > 10000 AND T2.hirange < 50000 AND T1.title_ID = 'BU2075'
book_publishing_company
171
["titles", "employee", "roysched", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"price\", \"title_id\", \"title\", \"type\", \"ytd_sales\", \"advance\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_ord\", \"au_id\"], \"roysched\": [\"royalty\", \"title_id\"], \"sales\": [\"title_id\", \"qty\", \"ord_num\", \"stor_id\", \"payterms\", \"ord_date\"], \"publishers\": [\"state\", \"city\", \"country\", \"pub_name\", \"pub_id\"]}"
Among the titles with royalty percentage, which title has the greatest royalty percentage. State it's minimum range to enjoy this royalty percentage.
SELECT T1.title, T2.lorange FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id ORDER BY T2.royalty DESC LIMIT 1
book_publishing_company
172
["stores", "titles", "employee", "jobs", "roysched", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"type\", \"advance\", \"title\", \"title_id\", \"price\", \"ytd_sales\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_id\", \"au_ord\"], \"roysched\": [\"royalty\", \"title_id\", \"lorange\", \"hirange\"], \"sales\": [\"title_id\", \"qty\", \"stor_id\", \"ord_num\"], \"jobs\": [\"min_lvl\", \"max_lvl\", \"job_id\"]}"
Provide a list of titles together with its publisher name for all publishers located in the USA.
SELECT T1.title, T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'USA'
book_publishing_company
173
["stores", "titles", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"type\", \"ytd_sales\", \"advance\", \"title\", \"pub_id\", \"title_id\", \"royalty\", \"pubdate\", \"price\", \"notes\"], \"publishers\": [\"city\", \"state\", \"country\", \"pub_name\", \"pub_id\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"royaltyper\", \"title_id\"], \"sales\": [\"title_id\", \"payterms\", \"stor_id\", \"qty\", \"ord_num\"], \"stores\": [\"city\", \"stor_name\", \"state\", \"stor_address\", \"stor_id\", \"zip\"]}"
State the royalty percentage for the most year to date sale title within the 20000 range.
SELECT MAX(T1.ytd_sales) FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.lorange > 20000 AND T2.hirange < 20000
book_publishing_company
174
["stores", "titles", "employee", "roysched", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"ytd_sales\", \"pubdate\", \"price\", \"title\", \"title_id\", \"type\", \"advance\", \"pub_id\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_id\", \"au_ord\"], \"roysched\": [\"royalty\", \"title_id\", \"lorange\", \"hirange\"], \"sales\": [\"ord_date\", \"title_id\", \"qty\", \"stor_id\", \"ord_num\", \"payterms\"], \"employee\": [\"hire_date\"]}"
List all titles published in year 1991. Also provide notes details of the title and the publisher's name.
SELECT T1.title, T1.notes, T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991'
book_publishing_company
175
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"notes\", \"ytd_sales\", \"type\", \"title\", \"pubdate\", \"title_id\", \"pub_id\", \"royalty\", \"price\", \"advance\"], \"titleauthor\": [\"title_id\", \"royaltyper\", \"au_id\", \"au_ord\"], \"sales\": [\"title_id\", \"stor_id\", \"ord_date\", \"payterms\", \"qty\"], \"publishers\": [\"city\", \"state\", \"pub_name\", \"pub_id\", \"country\"], \"roysched\": [\"title_id\", \"royalty\", \"hirange\"]}"
List all titles with sales of quantity more than 20 and store located in the CA state.
SELECT T1.title, T2.qty FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN stores AS T3 ON T2.stor_id = T3.stor_id WHERE T2.qty > 20 AND T3.state = 'CA'
book_publishing_company
176
["stores", "titles", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"ytd_sales\", \"price\", \"type\", \"title\", \"title_id\", \"pub_id\", \"royalty\", \"advance\", \"pubdate\", \"notes\"], \"stores\": [\"state\", \"city\", \"stor_name\", \"stor_id\", \"stor_address\", \"zip\"], \"sales\": [\"title_id\", \"stor_id\", \"ord_num\", \"qty\", \"payterms\", \"ord_date\"], \"titleauthor\": [\"royaltyper\", \"au_ord\", \"title_id\", \"au_id\"], \"publishers\": [\"state\", \"city\", \"country\", \"pub_id\", \"pub_name\"]}"
Name the store with the highest quantity in sales? What is the least quantity title from the store's sale?
SELECT T3.stor_id, T2.title FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id INNER JOIN stores AS T3 ON T3.stor_id = T1.stor_id WHERE T3.stor_id = ( SELECT stor_id FROM sales GROUP BY stor_id ORDER BY SUM(qty) DESC LIMIT 1 ) GROUP BY T3.stor_id, T2.title ORDER BY SUM(T1.qty) ASC LIMIT 1
book_publishing_company
177
["stores", "titles", "roysched", "sales", "discounts", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"ytd_sales\", \"price\", \"type\", \"title\", \"title_id\", \"advance\", \"royalty\", \"pub_id\", \"pubdate\", \"notes\"], \"sales\": [\"title_id\", \"ord_num\", \"qty\", \"stor_id\", \"ord_date\", \"payterms\"], \"stores\": [\"stor_name\", \"city\", \"stor_id\", \"state\", \"zip\", \"stor_address\"], \"discounts\": [\"highqty\", \"lowqty\", \"discount\", \"discounttype\", \"stor_id\"], \"roysched\": [\"title_id\", \"royalty\", \"hirange\", \"lorange\"]}"
Name the title and publisher for title ID BU 2075. Provide all the royalty percentage for all ranges.
SELECT T1.title, T3.pub_name, T2.lorange, T2.hirange, T2.royalty FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T1.title_id = 'BU2075'
book_publishing_company
178
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"title\", \"type\", \"advance\", \"ytd_sales\", \"title_id\", \"price\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_ord\", \"au_id\"], \"roysched\": [\"royalty\", \"title_id\", \"hirange\", \"lorange\"], \"sales\": [\"title_id\", \"qty\", \"ord_num\", \"payterms\", \"stor_id\", \"ord_date\"], \"publishers\": [\"city\", \"state\", \"pub_name\", \"pub_id\", \"country\"]}"
Name the store with ID 7066 and calculate the percentage of the the quantity ordered that were on 'Net 30' payment terms.
SELECT T2.stor_name , CAST(SUM(CASE WHEN payterms = 'Net 30' THEN qty ELSE 0 END) AS REAL) * 100 / SUM(qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T1.stor_id = '7066' GROUP BY T2.stor_name
book_publishing_company
179
["stores", "titles", "roysched", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"stor_name\", \"state\", \"stor_id\", \"stor_address\", \"zip\"], \"discounts\": [\"discount\", \"discounttype\", \"lowqty\", \"highqty\", \"stor_id\"], \"sales\": [\"payterms\", \"qty\", \"ord_date\", \"stor_id\", \"ord_num\", \"title_id\"], \"titles\": [\"price\", \"ytd_sales\", \"royalty\", \"advance\"], \"publishers\": [\"city\", \"state\", \"pub_name\", \"country\", \"pub_id\"]}"
State the publisher name for publisher ID 877? Calculate its average year to date sales.
SELECT T2.pub_name, AVG(T1.ytd_sales) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.pub_id = '0877' GROUP BY T2.pub_name
book_publishing_company
180
["stores", "titles", "employee", "roysched", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"sales\": [\"ord_date\", \"payterms\", \"title_id\", \"ord_num\", \"qty\", \"stor_id\"], \"employee\": [\"hire_date\", \"job_lvl\", \"emp_id\", \"fname\", \"lname\", \"job_id\", \"pub_id\", \"minit\"], \"titles\": [\"ytd_sales\", \"pubdate\", \"price\", \"title_id\", \"type\", \"advance\", \"royalty\", \"title\", \"notes\", \"pub_id\"], \"publishers\": [\"state\", \"pub_id\", \"country\", \"city\", \"pub_name\"], \"stores\": [\"state\", \"stor_name\", \"city\", \"stor_id\", \"stor_address\", \"zip\"]}"
Name all employees who were hired before year 1990.
SELECT fname, lname FROM employee WHERE STRFTIME('%Y', hire_date) < '1990'
book_publishing_company
181
["titles", "employee", "jobs", "roysched", "authors", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"hire_date\", \"job_lvl\", \"job_id\", \"minit\", \"fname\", \"lname\", \"emp_id\", \"pub_id\"], \"jobs\": [\"job_desc\", \"job_id\", \"min_lvl\", \"max_lvl\"], \"publishers\": [\"city\", \"state\", \"pub_name\", \"pub_id\", \"country\"], \"titles\": [\"ytd_sales\", \"title\", \"title_id\", \"type\", \"pubdate\", \"royalty\", \"pub_id\", \"advance\"], \"roysched\": [\"hirange\", \"title_id\", \"lorange\", \"royalty\"]}"
Which employee has the lowest job level. State the first name, last name and when he /she was hired.
SELECT fname, lname, hire_date FROM employee ORDER BY job_lvl LIMIT 1
book_publishing_company
182
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"hire_date\", \"job_id\", \"minit\", \"lname\", \"fname\", \"pub_id\", \"emp_id\"], \"jobs\": [\"min_lvl\", \"job_desc\", \"job_id\", \"max_lvl\"], \"discounts\": [\"lowqty\", \"discount\", \"discounttype\", \"highqty\", \"stor_id\"], \"publishers\": [\"state\", \"pub_name\", \"city\"], \"stores\": [\"state\", \"stor_name\", \"stor_id\", \"city\", \"zip\"]}"
In which year has the most hired employees?
SELECT STRFTIME('%Y', hire_date) FROM employee GROUP BY STRFTIME('%Y', hire_date) ORDER BY COUNT(emp_id) DESC LIMIT 1
book_publishing_company
183
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"hire_date\", \"job_id\", \"job_lvl\", \"fname\", \"lname\", \"minit\", \"emp_id\", \"pub_id\"], \"jobs\": [\"max_lvl\", \"job_desc\", \"min_lvl\", \"job_id\"], \"stores\": [\"city\", \"state\", \"stor_id\", \"stor_name\", \"stor_address\", \"zip\"], \"publishers\": [\"city\", \"state\", \"country\", \"pub_name\", \"pub_id\"], \"authors\": [\"city\", \"state\", \"au_lname\", \"au_id\", \"au_fname\", \"contract\"]}"
List all employees who are at the maximum level in their job designation.
SELECT T1.fname, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl = T2.max_lvl
book_publishing_company
184
["stores", "titles", "employee", "jobs", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"job_id\", \"hire_date\", \"fname\", \"minit\", \"lname\", \"pub_id\", \"emp_id\"], \"jobs\": [\"max_lvl\", \"job_desc\", \"min_lvl\", \"job_id\"], \"discounts\": [\"highqty\", \"stor_id\", \"discount\"], \"stores\": [\"city\", \"stor_name\", \"stor_id\", \"state\", \"stor_address\"], \"titles\": [\"ytd_sales\", \"title_id\", \"title\", \"type\", \"pub_id\", \"pubdate\", \"advance\", \"notes\", \"royalty\", \"price\"]}"
Name the Chief Executive Officer and when he/she was hired.
SELECT T1.fname, T1.lname, T1.hire_date FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T2.job_desc = 'Chief Financial Officier'
book_publishing_company
185
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"hire_date\", \"job_lvl\", \"job_id\", \"fname\", \"emp_id\", \"lname\", \"minit\", \"pub_id\"], \"jobs\": [\"job_desc\", \"job_id\", \"min_lvl\", \"max_lvl\"], \"roysched\": [\"hirange\", \"lorange\", \"royalty\", \"title_id\"], \"sales\": [\"ord_date\", \"qty\", \"ord_num\", \"title_id\", \"payterms\"], \"stores\": [\"stor_name\", \"city\", \"stor_id\"]}"
Who are the employees working for publisher not located in USA? State the employee's name and publisher name.
SELECT T1.fname, T1.lname, T2.pub_name FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country != 'USA'
book_publishing_company
186
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"job_id\", \"fname\", \"lname\", \"hire_date\", \"pub_id\", \"minit\", \"emp_id\"], \"publishers\": [\"state\", \"city\", \"country\", \"pub_name\", \"pub_id\"], \"authors\": [\"state\", \"city\", \"au_lname\", \"au_id\", \"au_fname\", \"address\", \"contract\"], \"jobs\": [\"job_desc\", \"job_id\", \"min_lvl\", \"max_lvl\"], \"stores\": [\"state\", \"city\", \"stor_name\", \"stor_id\", \"stor_address\"]}"
List all employees working for publisher 'GGG&G'. State their name and job description.
SELECT T1.fname, T1.lname, T3.job_desc FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T1.job_id = T3.job_id WHERE T2.pub_name = 'GGG&G'
book_publishing_company
187
["stores", "titles", "employee", "jobs", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_id\", \"job_lvl\", \"hire_date\", \"fname\", \"lname\", \"minit\", \"pub_id\", \"emp_id\"], \"jobs\": [\"job_desc\", \"job_id\", \"min_lvl\", \"max_lvl\"], \"publishers\": [\"state\", \"city\", \"pub_name\", \"country\", \"pub_id\"], \"stores\": [\"city\", \"state\", \"stor_name\", \"stor_id\"], \"authors\": [\"city\", \"state\", \"au_lname\", \"au_fname\", \"au_id\", \"address\", \"contract\"]}"
For each publisher, state the type of titles they published order by the publisher name.
SELECT DISTINCT T2.pub_name, T1.type FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T2.pub_name
book_publishing_company
188
["titles", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"type\", \"ytd_sales\", \"royalty\", \"title_id\", \"pub_id\", \"title\", \"advance\", \"pubdate\", \"price\", \"notes\"], \"publishers\": [\"state\", \"pub_name\", \"city\", \"pub_id\", \"country\"], \"titleauthor\": [\"title_id\", \"royaltyper\", \"au_ord\", \"au_id\"], \"sales\": [\"title_id\", \"payterms\", \"ord_num\", \"qty\", \"stor_id\", \"ord_date\"], \"authors\": [\"state\", \"au_id\", \"au_lname\", \"au_fname\", \"city\", \"contract\", \"address\"]}"
Name the publisher which has the most titles published in 1991.
SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE STRFTIME('%Y', T1.pubdate) = '1991' GROUP BY T1.pub_id, T2.pub_name ORDER BY COUNT(T1.title_id) DESC LIMIT 1
book_publishing_company
189
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"type\", \"ytd_sales\", \"title\", \"royalty\", \"title_id\", \"pubdate\", \"pub_id\", \"price\", \"advance\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_id\", \"au_ord\"], \"publishers\": [\"city\", \"state\", \"pub_name\", \"country\", \"pub_id\"], \"roysched\": [\"title_id\", \"lorange\", \"royalty\", \"hirange\"], \"sales\": [\"title_id\", \"stor_id\", \"qty\", \"payterms\", \"ord_num\"]}"
Name the title with the highest price published by 'Binnet & Hardley'.
SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'Binnet & Hardley' ORDER BY T1.price DESC LIMIT 1
book_publishing_company
190
["stores", "titles", "roysched", "sales", "discounts", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"type\", \"title_id\", \"title\", \"advance\", \"ytd_sales\", \"pubdate\", \"royalty\", \"pub_id\", \"notes\"], \"discounts\": [\"highqty\", \"discount\", \"discounttype\", \"stor_id\", \"lowqty\"], \"titleauthor\": [\"title_id\", \"au_id\", \"au_ord\", \"royaltyper\"], \"roysched\": [\"title_id\", \"royalty\", \"hirange\", \"lorange\"], \"sales\": [\"title_id\", \"qty\", \"payterms\", \"ord_num\", \"ord_date\"]}"
Among all employees, who have job level greater than 200. State the employee name and job description.
SELECT T1.fname, T1.lname, T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.job_lvl > 200
book_publishing_company
191
["stores", "titles", "employee", "jobs", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"job_id\", \"hire_date\", \"lname\", \"minit\", \"fname\", \"pub_id\", \"emp_id\"], \"jobs\": [\"max_lvl\", \"job_desc\", \"job_id\", \"min_lvl\"], \"publishers\": [\"state\", \"city\", \"pub_name\"], \"authors\": [\"state\", \"city\", \"au_lname\", \"au_fname\", \"au_id\"], \"stores\": [\"state\", \"city\", \"stor_name\", \"stor_id\"]}"
Name all the authors for all business titles.
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.type = 'business'
book_publishing_company
192
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"type\", \"title\", \"title_id\", \"advance\", \"pub_id\", \"royalty\", \"ytd_sales\", \"pubdate\", \"notes\", \"price\"], \"authors\": [\"city\", \"au_lname\", \"au_fname\", \"au_id\", \"contract\", \"state\", \"address\", \"phone\", \"zip\"], \"titleauthor\": [\"title_id\", \"royaltyper\", \"au_ord\", \"au_id\"], \"sales\": [\"title_id\", \"payterms\", \"ord_num\", \"qty\", \"stor_id\"], \"roysched\": [\"title_id\", \"hirange\", \"lorange\", \"royalty\"]}"
List all the titles and year to date sales by author who are not on contract.
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
book_publishing_company
193
["titles", "employee", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"ytd_sales\", \"pubdate\", \"title_id\", \"title\", \"type\", \"advance\", \"pub_id\", \"royalty\", \"price\", \"notes\"], \"authors\": [\"contract\", \"au_id\", \"au_lname\", \"au_fname\", \"city\", \"state\", \"zip\", \"address\", \"phone\"], \"sales\": [\"ord_date\", \"title_id\", \"qty\", \"ord_num\", \"stor_id\", \"payterms\"], \"titleauthor\": [\"au_ord\", \"title_id\", \"au_id\", \"royaltyper\"], \"employee\": [\"hire_date\", \"fname\"]}"
For all authors from CA who are not on contract, which title of his/hers has the most year to date sales.
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
book_publishing_company
194
["stores", "titles", "employee", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"authors\": [\"contract\", \"state\", \"city\", \"au_id\", \"au_lname\", \"au_fname\", \"address\", \"zip\", \"phone\"], \"titles\": [\"ytd_sales\", \"pubdate\", \"title\", \"title_id\", \"type\", \"pub_id\", \"advance\", \"price\", \"royalty\", \"notes\"], \"sales\": [\"ord_date\", \"title_id\", \"stor_id\", \"qty\", \"ord_num\", \"payterms\"], \"titleauthor\": [\"title_id\", \"au_id\", \"au_ord\", \"royaltyper\"], \"employee\": [\"hire_date\", \"pub_id\"]}"
Name all the authors for 'Sushi, Anyone?'.
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?'
book_publishing_company
195
["stores", "titles", "roysched", "authors", "sales", "pub_info", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"authors\": [\"city\", \"au_id\", \"au_lname\", \"au_fname\", \"address\", \"contract\", \"state\", \"zip\", \"phone\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"royaltyper\", \"title_id\"], \"roysched\": [\"lorange\", \"hirange\", \"title_id\", \"royalty\"], \"discounts\": [\"lowqty\", \"discounttype\", \"highqty\", \"discount\", \"stor_id\"], \"stores\": [\"city\", \"stor_name\", \"stor_id\", \"stor_address\"]}"
Calculate the percentage of the employees who are Editor or Designer?
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
book_publishing_company
196
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"hire_date\", \"job_id\", \"lname\", \"emp_id\", \"minit\", \"fname\", \"pub_id\"], \"jobs\": [\"min_lvl\", \"max_lvl\", \"job_id\", \"job_desc\"], \"publishers\": [\"city\", \"pub_id\", \"pub_name\", \"country\", \"state\"], \"authors\": [\"city\", \"au_lname\", \"au_id\", \"au_fname\", \"state\", \"zip\", \"contract\"], \"discounts\": [\"discount\", \"lowqty\", \"discounttype\", \"stor_id\", \"highqty\"]}"
List all titles which have year to date sales higher than the average order by pubisher name.
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 )
book_publishing_company
197
["stores", "titles", "sales", "pub_info", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"pubdate\", \"ytd_sales\", \"pub_id\", \"price\", \"advance\", \"type\", \"title_id\", \"royalty\", \"title\", \"notes\"], \"sales\": [\"ord_date\", \"title_id\", \"stor_id\", \"payterms\", \"qty\", \"ord_num\"], \"discounts\": [\"highqty\", \"stor_id\", \"discount\", \"discounttype\", \"lowqty\"], \"publishers\": [\"pub_name\", \"pub_id\", \"city\", \"country\", \"state\"], \"pub_info\": [\"pub_id\", \"logo\", \"pr_info\"]}"
How many publishers are in the USA?
SELECT COUNT(pub_id) FROM publishers WHERE country = 'USA'
book_publishing_company
198
["stores", "titles", "employee", "jobs", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"state\", \"city\", \"country\", \"pub_id\", \"pub_name\"], \"authors\": [\"state\", \"city\", \"au_id\", \"au_fname\", \"address\", \"au_lname\", \"contract\", \"phone\", \"zip\"], \"stores\": [\"state\", \"city\", \"stor_id\", \"stor_address\", \"stor_name\", \"zip\"], \"titles\": [\"ytd_sales\", \"pub_id\", \"type\", \"royalty\", \"advance\", \"title\", \"price\", \"title_id\", \"pubdate\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"royaltyper\", \"title_id\"]}"
What is the publisher's information of New Moon Books?
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'
book_publishing_company
199
["titles", "authors", "pub_info", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"pub_id\", \"city\", \"state\", \"pub_name\", \"country\"], \"authors\": [\"city\", \"au_id\", \"state\", \"address\", \"zip\", \"au_fname\", \"au_lname\", \"contract\", \"phone\"], \"titles\": [\"pubdate\", \"pub_id\", \"advance\", \"type\", \"ytd_sales\", \"royalty\", \"title\", \"notes\", \"price\", \"title_id\"], \"pub_info\": [\"pub_id\", \"pr_info\", \"logo\"], \"titleauthor\": [\"au_id\", \"au_ord\", \"royaltyper\", \"title_id\"]}"
Please list the first names of the employees who work as Managing Editor.
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'
book_publishing_company
200
["titles", "employee", "jobs", "roysched", "authors", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_id\", \"job_lvl\", \"hire_date\", \"fname\", \"lname\", \"minit\", \"pub_id\", \"emp_id\"], \"jobs\": [\"job_desc\", \"job_id\", \"min_lvl\", \"max_lvl\"], \"authors\": [\"au_lname\", \"city\", \"au_fname\", \"au_id\", \"contract\", \"zip\", \"state\", \"phone\", \"address\"], \"roysched\": [\"hirange\", \"royalty\", \"lorange\", \"title_id\"], \"publishers\": [\"pub_name\", \"city\", \"pub_id\", \"country\", \"state\"]}"
What is the highest level of job to get to for the employee who got hired the earliest?
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
book_publishing_company
201
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"hire_date\", \"job_lvl\", \"job_id\", \"minit\", \"lname\", \"emp_id\", \"fname\", \"pub_id\"], \"jobs\": [\"max_lvl\", \"min_lvl\", \"job_desc\", \"job_id\"], \"discounts\": [\"highqty\", \"lowqty\", \"discount\"], \"roysched\": [\"hirange\", \"lorange\", \"title_id\", \"royalty\"], \"stores\": [\"city\", \"zip\", \"stor_name\", \"state\", \"stor_id\", \"stor_address\"]}"
In which city is the store with the highest total sales quantity located?
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
book_publishing_company
202
["stores", "titles", "employee", "jobs", "roysched", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"state\", \"stor_id\", \"stor_name\", \"stor_address\", \"zip\"], \"discounts\": [\"highqty\", \"discount\", \"stor_id\", \"discounttype\", \"lowqty\"], \"publishers\": [\"city\", \"state\", \"country\", \"pub_id\", \"pub_name\"], \"sales\": [\"ord_num\", \"stor_id\", \"qty\", \"ord_date\", \"title_id\", \"payterms\"], \"titles\": [\"ytd_sales\", \"price\", \"title_id\", \"pubdate\", \"title\", \"type\"]}"
What is the price of the book that sells the best?
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
book_publishing_company
203
["stores", "titles", "roysched", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"ytd_sales\", \"royalty\", \"title_id\", \"title\", \"pub_id\", \"type\", \"advance\", \"pubdate\"], \"discounts\": [\"discount\", \"highqty\", \"discounttype\", \"stor_id\", \"lowqty\"], \"sales\": [\"qty\", \"payterms\", \"title_id\", \"stor_id\", \"ord_num\", \"ord_date\"], \"roysched\": [\"royalty\", \"hirange\", \"title_id\", \"lorange\"], \"titleauthor\": [\"royaltyper\", \"au_id\", \"au_ord\", \"title_id\"]}"
Please list the stores that ordered the book "Life Without Fear".
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'
book_publishing_company
204
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"state\", \"stor_name\", \"zip\", \"stor_id\", \"stor_address\"], \"discounts\": [\"highqty\", \"lowqty\", \"discount\", \"stor_id\", \"discounttype\"], \"publishers\": [\"city\", \"state\", \"country\", \"pub_id\", \"pub_name\"], \"roysched\": [\"lorange\", \"hirange\", \"royalty\", \"title_id\"], \"authors\": [\"city\", \"zip\", \"au_id\", \"au_fname\", \"state\", \"phone\", \"address\"]}"
Among the stores that have ordered the book "Life Without Fear", how many of them are located in Massachusetts?
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'
book_publishing_company
205
["stores", "titles", "employee", "jobs", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"state\", \"zip\", \"stor_name\", \"stor_address\", \"stor_id\"], \"titleauthor\": [\"au_id\", \"au_ord\", \"title_id\"], \"publishers\": [\"city\", \"state\", \"pub_id\", \"country\", \"pub_name\"], \"discounts\": [\"highqty\", \"lowqty\", \"discounttype\", \"stor_id\", \"discount\"], \"authors\": [\"city\", \"state\", \"zip\", \"address\", \"au_id\", \"phone\", \"au_fname\", \"contract\", \"au_lname\"]}"
In which country is the publisher of the book "Life Without Fear" located?
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'
book_publishing_company
206
["stores", "titles", "employee", "roysched", "authors", "sales", "pub_info", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"country\", \"city\", \"state\", \"pub_id\", \"pub_name\"], \"authors\": [\"city\", \"au_id\", \"au_fname\", \"address\", \"state\", \"au_lname\", \"contract\", \"zip\", \"phone\"], \"titleauthor\": [\"au_id\", \"au_ord\", \"title_id\", \"royaltyper\"], \"stores\": [\"city\", \"state\", \"stor_name\", \"stor_address\", \"zip\", \"stor_id\"], \"pub_info\": [\"pr_info\", \"logo\"]}"
What is the publisher that has published the most expensive book?
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
book_publishing_company
207
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"city\", \"state\", \"pub_id\", \"country\", \"pub_name\"], \"authors\": [\"au_id\", \"city\", \"au_fname\", \"state\", \"au_lname\", \"address\", \"contract\", \"zip\", \"phone\"], \"titles\": [\"price\", \"pub_id\", \"pubdate\", \"royalty\", \"advance\", \"type\", \"ytd_sales\", \"title\", \"title_id\"], \"titleauthor\": [\"au_id\", \"au_ord\", \"royaltyper\", \"title_id\"], \"roysched\": [\"hirange\", \"lorange\", \"royalty\", \"title_id\"]}"
Among the publishers in the USA, how many of them have published books that are over $15?
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
book_publishing_company
208
["stores", "titles", "employee", "jobs", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"city\", \"state\", \"country\", \"pub_id\", \"pub_name\"], \"authors\": [\"city\", \"state\", \"au_id\", \"au_fname\", \"contract\", \"au_lname\", \"zip\", \"address\", \"phone\"], \"stores\": [\"city\", \"state\", \"stor_id\", \"stor_name\", \"stor_address\", \"zip\"], \"discounts\": [\"highqty\", \"stor_id\", \"lowqty\", \"discount\", \"discounttype\"], \"titles\": [\"price\", \"ytd_sales\", \"pub_id\", \"type\", \"royalty\", \"advance\", \"pubdate\", \"title\", \"title_id\"]}"
Please give more detailed information about the first three books that sell the best.
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
book_publishing_company
209
["stores", "titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"ytd_sales\", \"advance\", \"price\", \"royalty\", \"pub_id\", \"title_id\", \"title\", \"type\", \"notes\", \"pubdate\"], \"authors\": [\"city\", \"au_id\", \"au_lname\", \"au_fname\", \"state\", \"contract\", \"address\", \"phone\", \"zip\"], \"sales\": [\"stor_id\", \"ord_num\", \"qty\", \"title_id\", \"payterms\", \"ord_date\"], \"roysched\": [\"royalty\", \"lorange\", \"hirange\", \"title_id\"], \"stores\": [\"city\", \"stor_name\", \"stor_id\", \"state\", \"stor_address\"]}"
How many books on business have the bookstores in Massachusetts ordered?
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'
book_publishing_company
210
["stores", "titles", "employee", "jobs", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"state\", \"stor_address\", \"stor_id\", \"stor_name\", \"zip\"], \"publishers\": [\"city\", \"state\", \"pub_id\", \"pub_name\", \"country\"], \"authors\": [\"city\", \"state\", \"address\", \"au_id\", \"au_fname\", \"phone\", \"zip\", \"au_lname\", \"contract\"], \"discounts\": [\"discount\", \"stor_id\", \"highqty\", \"discounttype\", \"lowqty\"], \"titles\": [\"pub_id\", \"ytd_sales\", \"price\", \"type\", \"title_id\", \"royalty\", \"title\", \"pubdate\", \"notes\", \"advance\"]}"
What is the average quantity of each order for the book "Life Without Fear"?
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'
book_publishing_company
211
["stores", "titles", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"discounts\": [\"lowqty\", \"highqty\", \"discount\", \"discounttype\", \"stor_id\"], \"titles\": [\"price\", \"advance\", \"ytd_sales\", \"royalty\", \"type\", \"pub_id\", \"pubdate\"], \"authors\": [\"zip\", \"contract\", \"city\", \"au_id\", \"address\", \"phone\", \"au_fname\", \"state\", \"au_lname\"], \"roysched\": [\"lorange\", \"royalty\", \"hirange\", \"title_id\"], \"publishers\": [\"country\", \"state\", \"pub_id\", \"city\", \"pub_name\"]}"
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?
SELECT AVG(T2.job_lvl), T1.max_lvl - AVG(T2.job_lvl) FROM jobs AS T1 INNER JOIN employee AS T2 ON T1.job_id = T2.job_id WHERE T1.job_desc = 'Managing Editor' GROUP BY T2.job_id, T1.max_lvl
book_publishing_company
212
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"emp_id\", \"job_id\", \"fname\", \"lname\", \"pub_id\", \"hire_date\", \"minit\"], \"jobs\": [\"max_lvl\", \"min_lvl\", \"job_desc\", \"job_id\"], \"discounts\": [\"highqty\"], \"titles\": [\"title\", \"price\", \"title_id\", \"advance\", \"pub_id\", \"type\", \"pubdate\", \"royalty\", \"ytd_sales\", \"notes\"], \"roysched\": [\"title_id\", \"hirange\", \"lorange\", \"royalty\"]}"
Which one is the cheapest business book?
SELECT title FROM titles WHERE type = 'business' ORDER BY price LIMIT 1
book_publishing_company
213
["stores", "titles", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"discounts\": [\"lowqty\", \"stor_id\", \"discount\", \"discounttype\", \"highqty\"], \"publishers\": [\"state\", \"city\", \"pub_id\", \"country\", \"pub_name\"], \"stores\": [\"city\", \"state\", \"stor_id\", \"stor_address\", \"stor_name\", \"zip\"], \"authors\": [\"city\", \"zip\", \"state\", \"phone\", \"address\", \"au_fname\", \"contract\", \"au_id\", \"au_lname\"], \"titles\": [\"price\", \"ytd_sales\", \"pub_id\", \"type\", \"royalty\"]}"
Which type of book had the most pre-paid amount?
SELECT type FROM titles ORDER BY advance DESC LIMIT 1
book_publishing_company
214
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"sales\": [\"payterms\", \"qty\"], \"discounts\": [\"lowqty\", \"discount\", \"discounttype\", \"stor_id\", \"highqty\"], \"publishers\": [\"pub_id\", \"city\", \"pub_name\", \"state\", \"country\"], \"authors\": [\"contract\", \"city\", \"au_id\", \"au_fname\", \"au_lname\", \"zip\", \"state\"], \"roysched\": [\"lorange\", \"hirange\", \"royalty\", \"title_id\"]}"
What's the royalty for the bestseller book?
SELECT royalty FROM titles ORDER BY ytd_sales DESC LIMIT 1
book_publishing_company
215
["stores", "titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"roysched\": [\"royalty\", \"lorange\", \"hirange\", \"title_id\"], \"titles\": [\"royalty\", \"ytd_sales\", \"price\", \"type\", \"title_id\", \"title\", \"advance\", \"pub_id\", \"pubdate\"], \"titleauthor\": [\"royaltyper\", \"au_id\", \"au_ord\", \"title_id\"], \"sales\": [\"title_id\", \"qty\", \"stor_id\", \"payterms\", \"ord_num\", \"ord_date\"], \"authors\": [\"au_id\", \"au_lname\", \"city\", \"au_fname\", \"state\", \"contract\", \"address\", \"phone\", \"zip\"]}"
Which job level is O'Rourke at?
SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'
book_publishing_company
216
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"jobs\": [\"job_desc\", \"job_id\", \"max_lvl\", \"min_lvl\"], \"employee\": [\"job_lvl\", \"job_id\", \"hire_date\", \"pub_id\", \"minit\", \"fname\", \"emp_id\", \"lname\"], \"authors\": [\"city\", \"au_id\", \"au_lname\", \"au_fname\", \"state\", \"contract\", \"zip\", \"address\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"title_id\", \"royaltyper\"], \"stores\": [\"city\", \"stor_name\", \"stor_id\", \"stor_address\", \"state\", \"zip\"]}"
Show me the employ id of the highest employee who doesn't have a middle name.
SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1
book_publishing_company
217
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"hire_date\", \"job_id\", \"lname\", \"fname\", \"minit\", \"emp_id\", \"pub_id\"], \"jobs\": [\"max_lvl\", \"min_lvl\", \"job_desc\", \"job_id\"], \"discounts\": [\"highqty\", \"lowqty\", \"discount\", \"discounttype\"], \"roysched\": [\"lorange\", \"royalty\", \"hirange\", \"title_id\"], \"stores\": [\"stor_name\", \"city\", \"stor_id\"]}"
Is the author of "Sushi, Anyone?" on the contract?
SELECT T1.contract FROM authors AS T1 INNER JOIN titleauthor AS T2 ON T1.au_id = T2.au_id INNER JOIN titles AS T3 ON T2.title_id = T3.title_id WHERE T3.title = 'Sushi, Anyone?'
book_publishing_company
218
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"authors\": [\"contract\", \"au_id\", \"city\", \"au_fname\", \"au_lname\", \"phone\", \"state\", \"zip\", \"address\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"title_id\", \"royaltyper\"], \"discounts\": [\"lowqty\", \"highqty\", \"discounttype\", \"discount\", \"stor_id\"], \"titles\": [\"pubdate\", \"price\", \"title\", \"pub_id\", \"title_id\", \"notes\", \"advance\", \"type\", \"ytd_sales\"], \"roysched\": [\"title_id\", \"lorange\", \"hirange\", \"royalty\"]}"
Which publisher had the highest job level? Give his/her full name.
SELECT T1.fname, T1.minit, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.job_lvl DESC LIMIT 1
book_publishing_company
219
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"jobs\": [\"max_lvl\", \"job_desc\", \"job_id\", \"min_lvl\"], \"employee\": [\"job_lvl\", \"job_id\", \"hire_date\", \"fname\", \"lname\", \"minit\", \"pub_id\", \"emp_id\"], \"discounts\": [\"highqty\", \"discount\", \"discounttype\"], \"publishers\": [\"city\", \"state\", \"pub_name\", \"pub_id\", \"country\"], \"stores\": [\"stor_name\", \"city\", \"stor_id\", \"state\"]}"
What's Pedro S Afonso's job title?
SELECT T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Pedro' AND T1.minit = 'S' AND T1.lname = 'Afonso'
book_publishing_company
220
["titles", "employee", "jobs", "roysched", "authors", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titleauthor\": [\"au_id\", \"au_ord\", \"title_id\", \"royaltyper\"], \"jobs\": [\"job_desc\", \"job_id\", \"max_lvl\", \"min_lvl\"], \"titles\": [\"type\", \"title\", \"pubdate\", \"title_id\", \"pub_id\", \"advance\", \"notes\", \"ytd_sales\", \"price\", \"royalty\"], \"employee\": [\"job_lvl\", \"job_id\", \"hire_date\", \"emp_id\", \"fname\", \"pub_id\", \"minit\", \"lname\"], \"roysched\": [\"title_id\", \"lorange\", \"royalty\", \"hirange\"]}"
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?
SELECT T2.max_lvl - T1.job_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Diego' AND T1.minit = 'W' AND T1.lname = 'Roel'
book_publishing_company
221
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"jobs\": [\"max_lvl\", \"min_lvl\", \"job_desc\", \"job_id\"], \"employee\": [\"job_lvl\", \"minit\", \"hire_date\", \"job_id\", \"emp_id\", \"pub_id\", \"lname\"], \"authors\": [\"city\", \"contract\", \"au_id\", \"au_lname\", \"state\", \"zip\", \"au_fname\", \"phone\", \"address\"], \"roysched\": [\"lorange\", \"hirange\", \"title_id\"], \"titles\": [\"advance\", \"price\", \"pubdate\", \"title\", \"pub_id\", \"title_id\", \"ytd_sales\", \"type\"]}"
What's on the notes for the order happened on 1994/9/14?
SELECT T1.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1994-09-14'
book_publishing_company
222
["stores", "titles", "employee", "sales", "pub_info", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"notes\", \"pubdate\", \"ytd_sales\", \"title\", \"pub_id\", \"type\", \"advance\"], \"employee\": [\"hire_date\", \"emp_id\", \"job_lvl\", \"pub_id\", \"job_id\"], \"sales\": [\"ord_date\", \"payterms\", \"ord_num\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"title_id\", \"royaltyper\"], \"publishers\": [\"city\", \"state\", \"pub_id\", \"pub_name\", \"country\"]}"
List the type of the book for the order which was sold on 1993/5/29.
SELECT DISTINCT T1.type FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE STRFTIME('%Y-%m-%d', T2.ord_date) = '1993-05-29'
book_publishing_company
223
["stores", "titles", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"ytd_sales\", \"type\", \"price\", \"pubdate\", \"pub_id\", \"advance\", \"royalty\", \"notes\", \"title_id\", \"title\"], \"sales\": [\"ord_date\", \"payterms\", \"qty\", \"ord_num\", \"stor_id\", \"title_id\"], \"discounts\": [\"discounttype\", \"discount\", \"lowqty\", \"stor_id\", \"highqty\"], \"publishers\": [\"city\", \"pub_id\", \"pub_name\", \"state\", \"country\"], \"stores\": [\"city\", \"stor_id\", \"stor_name\", \"state\", \"zip\", \"stor_address\"]}"
Tell me about the information of the French publisher.
SELECT T1.pr_info FROM pub_info AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'France'
book_publishing_company
224
["titles", "roysched", "authors", "pub_info", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"city\", \"country\", \"state\", \"pub_id\", \"pub_name\"], \"pub_info\": [\"pr_info\", \"pub_id\", \"logo\"], \"authors\": [\"city\", \"au_id\", \"au_fname\", \"au_lname\", \"phone\", \"contract\", \"address\", \"state\", \"zip\"], \"roysched\": [\"royalty\", \"lorange\", \"hirange\", \"title_id\"], \"titleauthor\": [\"au_ord\", \"royaltyper\", \"au_id\", \"title_id\"]}"
What's the publisher of the book "Silicon Valley Gastronomic Treats"? Give the publisher's name.
SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Silicon Valley Gastronomic Treats'
book_publishing_company
225
["stores", "titles", "roysched", "authors", "sales", "pub_info", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"city\", \"state\", \"pub_name\", \"pub_id\", \"country\"], \"authors\": [\"city\", \"state\", \"contract\", \"au_fname\", \"address\", \"au_id\", \"au_lname\", \"phone\", \"zip\"], \"stores\": [\"city\", \"stor_name\", \"state\", \"stor_id\"], \"titleauthor\": [\"au_ord\", \"au_id\", \"royaltyper\", \"title_id\"], \"titles\": [\"type\", \"advance\", \"pubdate\", \"pub_id\", \"title\", \"royalty\", \"ytd_sales\", \"title_id\", \"price\"]}"
Which city did Victoria P Ashworth work in?
SELECT T2.city FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.fname = 'Victoria' AND T1.minit = 'P' AND T1.lname = 'Ashworth'
book_publishing_company
226
["stores", "titles", "employee", "jobs", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"stor_address\", \"state\", \"zip\", \"stor_name\", \"stor_id\"], \"authors\": [\"city\", \"au_id\", \"state\", \"au_fname\", \"address\", \"au_lname\", \"contract\", \"zip\"], \"publishers\": [\"city\", \"state\", \"country\", \"pub_id\", \"pub_name\"], \"jobs\": [\"job_desc\", \"job_id\", \"max_lvl\", \"min_lvl\"], \"employee\": [\"hire_date\", \"job_id\", \"emp_id\", \"job_lvl\", \"minit\", \"pub_id\", \"fname\", \"lname\"]}"
How many sales did the store in Remulade make?
SELECT COUNT(T1.ord_num) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T2.city = 'Remulade'
book_publishing_company
227
["stores", "titles", "employee", "jobs", "roysched", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"state\", \"stor_id\", \"stor_name\", \"stor_address\", \"zip\"], \"titles\": [\"ytd_sales\", \"price\", \"royalty\", \"title\", \"title_id\", \"advance\", \"type\", \"notes\", \"pub_id\"], \"sales\": [\"ord_num\", \"qty\", \"stor_id\", \"title_id\", \"payterms\", \"ord_date\"], \"discounts\": [\"discount\", \"highqty\", \"discounttype\", \"stor_id\", \"lowqty\"], \"roysched\": [\"hirange\", \"lorange\", \"royalty\", \"title_id\"]}"
For the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993?
SELECT CAST(SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) - SUM(CASE WHEN T2.city = 'Portland' THEN qty END) AS REAL) * 100 / SUM(CASE WHEN T2.city = 'Fremont' THEN qty END) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE STRFTIME('%Y', T1.ord_date) = '1993'
book_publishing_company
228
["stores", "titles", "roysched", "sales", "publishers", "discounts"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"stores\": [\"city\", \"state\", \"zip\", \"stor_id\", \"stor_name\", \"stor_address\"], \"titles\": [\"ytd_sales\", \"price\", \"royalty\", \"title\", \"pub_id\", \"advance\"], \"sales\": [\"ord_num\", \"qty\", \"stor_id\", \"ord_date\", \"title_id\", \"payterms\"], \"publishers\": [\"city\", \"state\", \"pub_id\", \"pub_name\", \"country\"], \"discounts\": [\"discount\", \"discounttype\", \"stor_id\", \"lowqty\", \"highqty\"]}"
Among all the employees, how many percent more for the publishers than designers?
SELECT CAST(SUM(CASE WHEN T2.job_desc = 'publisher' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.job_desc = '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
book_publishing_company
229
["stores", "titles", "employee", "jobs", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"job_lvl\", \"job_id\", \"hire_date\", \"minit\", \"fname\", \"lname\", \"emp_id\", \"pub_id\"], \"publishers\": [\"city\", \"state\", \"country\", \"pub_id\", \"pub_name\"], \"jobs\": [\"max_lvl\", \"min_lvl\", \"job_desc\", \"job_id\"], \"authors\": [\"city\", \"au_id\", \"au_lname\", \"au_fname\", \"state\", \"address\", \"contract\", \"phone\", \"zip\"], \"stores\": [\"city\", \"stor_id\", \"stor_name\", \"state\"]}"
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.
SELECT fname, minit, lname FROM employee WHERE STRFTIME('%Y', hire_date) BETWEEN '1990' AND '1995' ORDER BY job_lvl DESC
book_publishing_company
230
["titles", "employee", "roysched", "sales", "publishers", "jobs"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"employee\": [\"hire_date\", \"job_lvl\", \"job_id\", \"minit\", \"fname\", \"lname\", \"emp_id\", \"pub_id\"], \"jobs\": [\"job_desc\", \"job_id\", \"min_lvl\", \"max_lvl\"], \"sales\": [\"ord_date\", \"title_id\", \"qty\", \"payterms\", \"ord_num\"], \"titles\": [\"ytd_sales\", \"pubdate\", \"title_id\", \"type\", \"title\", \"pub_id\", \"advance\", \"royalty\"], \"publishers\": [\"pub_name\", \"city\", \"state\", \"pub_id\", \"country\"]}"
Which titles has above average royalty rate? Give those title's name, type and price?
SELECT DISTINCT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.royalty > ( SELECT CAST(SUM(royalty) AS REAL) / COUNT(title_id) FROM roysched )
book_publishing_company
231
["stores", "titles", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"price\", \"type\", \"advance\", \"title_id\", \"title\", \"ytd_sales\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_id\", \"au_ord\"], \"roysched\": [\"royalty\", \"title_id\", \"hirange\", \"lorange\"], \"sales\": [\"title_id\", \"payterms\", \"qty\", \"ord_num\", \"ord_date\", \"stor_id\"], \"discounts\": [\"highqty\", \"discounttype\", \"discount\", \"lowqty\", \"stor_id\"]}"
In 1994 which title had less order quanty than the average order quantity? Find the title name, type and price.
SELECT DISTINCT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE T2.ord_date LIKE '1994%' AND T2.Qty < ( SELECT CAST(SUM(T4.qty) AS REAL) / COUNT(T3.title_id) FROM titles AS T3 INNER JOIN sales AS T4 ON T3.title_id = T4.title_id )
book_publishing_company
232
["stores", "titles", "roysched", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"ytd_sales\", \"type\", \"title_id\", \"title\", \"pub_id\", \"pubdate\", \"advance\", \"royalty\", \"notes\"], \"discounts\": [\"lowqty\", \"highqty\", \"discounttype\", \"discount\", \"stor_id\"], \"titleauthor\": [\"title_id\", \"royaltyper\", \"au_ord\", \"au_id\"], \"sales\": [\"title_id\", \"qty\", \"ord_date\", \"ord_num\", \"payterms\", \"stor_id\"], \"roysched\": [\"title_id\", \"royalty\", \"lorange\"]}"
List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.
SELECT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books' ORDER BY T1.price
book_publishing_company
233
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"type\", \"royalty\", \"pub_id\", \"ytd_sales\", \"pubdate\", \"title\", \"title_id\", \"advance\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"title_id\", \"au_id\", \"au_ord\"], \"sales\": [\"title_id\", \"payterms\", \"qty\", \"ord_date\", \"ord_num\"], \"roysched\": [\"title_id\", \"royalty\", \"hirange\"], \"publishers\": [\"pub_name\", \"pub_id\", \"city\", \"state\", \"country\"]}"
In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.
SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN roysched AS T3 ON T1.title_id = T3.title_id WHERE T2.country = 'USA' ORDER BY T1.royalty DESC
book_publishing_company
234
["stores", "titles", "roysched", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"ytd_sales\", \"type\", \"title_id\", \"pub_id\", \"price\", \"title\", \"advance\", \"pubdate\"], \"roysched\": [\"royalty\", \"hirange\", \"lorange\", \"title_id\"], \"titleauthor\": [\"royaltyper\", \"au_id\", \"au_ord\", \"title_id\"], \"publishers\": [\"city\", \"state\", \"pub_id\", \"country\", \"pub_name\"], \"discounts\": [\"highqty\", \"stor_id\", \"lowqty\"]}"
Find the difference between the average royalty of titles published by US and non US publishers?
SELECT (CAST(SUM(CASE WHEN T2.country = 'USA' THEN T1.royalty ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T2.country != 'USA' THEN T1.royalty ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.country != 'USA' THEN 1 ELSE 0 END)) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN roysched AS T3 ON T1.title_id = T3.title_id
book_publishing_company
235
["titles", "roysched", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"royalty\", \"advance\", \"type\", \"title\", \"title_id\", \"ytd_sales\", \"price\", \"pub_id\", \"pubdate\", \"notes\"], \"titleauthor\": [\"royaltyper\", \"au_id\", \"au_ord\", \"title_id\"], \"roysched\": [\"royalty\", \"title_id\"], \"publishers\": [\"country\", \"state\", \"city\", \"pub_id\", \"pub_name\"], \"sales\": [\"title_id\", \"qty\", \"ord_num\", \"stor_id\", \"payterms\", \"ord_date\"]}"
Calculate the average level difference between the Marketing editors hired by the US and non-US publishers?
SELECT (CAST(SUM(CASE WHEN T1.country = 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.country != 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country != 'USA' THEN 1 ELSE 0 END)) FROM publishers AS T1 INNER JOIN employee AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T2.job_id = T3.job_id WHERE T3.job_desc = 'Managing Editor'
book_publishing_company
236
["titles", "employee", "jobs", "authors", "sales", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"publishers\": [\"country\", \"city\", \"state\", \"pub_id\", \"pub_name\"], \"employee\": [\"hire_date\", \"job_lvl\", \"emp_id\"], \"jobs\": [\"min_lvl\", \"max_lvl\", \"job_desc\", \"job_id\"], \"authors\": [\"au_id\", \"city\", \"au_lname\", \"state\", \"au_fname\", \"address\", \"contract\", \"phone\", \"zip\"], \"titles\": [\"price\", \"ytd_sales\", \"advance\", \"title\", \"title_id\", \"pub_id\", \"type\", \"pubdate\", \"royalty\"]}"
Which title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book?
SELECT T1.title, T2.pub_name, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Helpful hints on how to use your electronic resources to the best advantage.'
book_publishing_company
237
["titles", "roysched", "sales", "pub_info", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"price\", \"pub_id\", \"type\", \"title\", \"pubdate\", \"ytd_sales\", \"title_id\", \"advance\", \"royalty\", \"notes\"], \"titleauthor\": [\"au_id\", \"au_ord\", \"title_id\", \"royaltyper\"], \"roysched\": [\"title_id\", \"royalty\"], \"publishers\": [\"pub_id\", \"pub_name\", \"city\", \"state\", \"country\"], \"sales\": [\"title_id\"]}"
Of the titles, which title is about the Carefully researched study of the effects of strong emotions on the body, which state-based publisher published this book, and what is the year-to-date sale?
SELECT T1.title, T2.pub_name, T1.ytd_sales FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Carefully researched study of the effects of strong emotions on the body. Metabolic charts included.'
book_publishing_company
238
["stores", "titles", "authors", "sales", "discounts", "publishers", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"pubdate\", \"ytd_sales\", \"type\", \"price\", \"advance\", \"title\", \"notes\", \"pub_id\", \"title_id\", \"royalty\"], \"titleauthor\": [\"au_id\", \"title_id\", \"au_ord\", \"royaltyper\"], \"sales\": [\"title_id\", \"ord_date\", \"stor_id\", \"qty\", \"payterms\", \"ord_num\"], \"authors\": [\"state\", \"city\", \"au_id\", \"au_fname\", \"au_lname\", \"contract\", \"address\", \"phone\", \"zip\"], \"publishers\": [\"state\", \"city\", \"pub_id\", \"pub_name\", \"country\"]}"
Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores?
SELECT T1.title FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T2.qty > ( SELECT CAST(SUM(qty) AS REAL) / COUNT(title_id) FROM sales ) AND T3.state = 'CA' ORDER BY T2.qty DESC LIMIT 5
book_publishing_company
239
["stores", "titles", "sales", "discounts", "titleauthor"]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
[ [ " CREATE TABLE authors ( au_id TEXT, au_lname TEXT NOT NULL, au_fname TEXT NOT NULL, phone TEXT NOT NULL, address TEXT, city TEXT, state TEXT, zip TEXT, contract TEXT NOT NULL, PRIMARY KEY (au_id) ) ", " CREATE TABLE discounts ( discounttype TEXT NOT NULL, stor_id TEXT, lowqty INTEGER, highqty INTEGER, discount REAL NOT NULL, FOREIGN KEY(stor_id) REFERENCES stores (stor_id) ) ", " CREATE TABLE employee ( emp_id TEXT, fname TEXT NOT NULL, minit TEXT, lname TEXT NOT NULL, job_id INTEGER NOT NULL, job_lvl INTEGER, pub_id TEXT NOT NULL, hire_date DATETIME NOT NULL, PRIMARY KEY (emp_id), FOREIGN KEY(job_id) REFERENCES jobs (job_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE jobs ( job_id INTEGER, job_desc TEXT NOT NULL, min_lvl INTEGER NOT NULL, max_lvl INTEGER NOT NULL, PRIMARY KEY (job_id) ) ", " CREATE TABLE pub_info ( pub_id TEXT, logo BLOB, pr_info TEXT, PRIMARY KEY (pub_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) ", " CREATE TABLE publishers ( pub_id TEXT, pub_name TEXT, city TEXT, state TEXT, country TEXT, PRIMARY KEY (pub_id) ) ", " CREATE TABLE roysched ( title_id TEXT NOT NULL, lorange INTEGER, hirange INTEGER, royalty INTEGER, FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE sales ( stor_id TEXT NOT NULL, ord_num TEXT NOT NULL, ord_date DATETIME NOT NULL, qty INTEGER NOT NULL, payterms TEXT NOT NULL, title_id TEXT NOT NULL, PRIMARY KEY (stor_id, ord_num, title_id), FOREIGN KEY(stor_id) REFERENCES stores (stor_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE stores ( stor_id TEXT, stor_name TEXT, stor_address TEXT, city TEXT, state TEXT, zip TEXT, PRIMARY KEY (stor_id) ) ", " CREATE TABLE titleauthor ( au_id TEXT NOT NULL, title_id TEXT NOT NULL, au_ord INTEGER, royaltyper INTEGER, PRIMARY KEY (au_id, title_id), FOREIGN KEY(au_id) REFERENCES authors (au_id), FOREIGN KEY(title_id) REFERENCES titles (title_id) ) ", " CREATE TABLE titles ( title_id TEXT, title TEXT NOT NULL, type TEXT NOT NULL, pub_id TEXT, price REAL, advance REAL, royalty INTEGER, ytd_sales INTEGER, notes TEXT, pubdate DATETIME NOT NULL, PRIMARY KEY (title_id), FOREIGN KEY(pub_id) REFERENCES publishers (pub_id) ) " ] ]
11
11
"{\"titles\": [\"ytd_sales\", \"price\", \"advance\", \"type\", \"royalty\", \"title\", \"title_id\", \"pub_id\", \"pubdate\", \"notes\"], \"sales\": [\"title_id\", \"qty\", \"ord_num\", \"stor_id\", \"ord_date\", \"payterms\"], \"stores\": [\"city\", \"stor_name\", \"state\", \"stor_id\", \"zip\", \"stor_address\"], \"titleauthor\": [\"royaltyper\", \"au_ord\", \"au_id\", \"title_id\"], \"discounts\": [\"discount\", \"highqty\", \"discounttype\", \"lowqty\", \"stor_id\"]}"
On which day was the most verbose complaint received?
SELECT `Date received` FROM callcenterlogs WHERE ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )
retail_complains
240
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Date received\", \"Complaint ID\", \"Date sent to company\", \"Timely response?\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Issue\", \"Submitted via\", \"Sub-issue\", \"Company response to consumer\", \"Product\", \"Tags\", \"Consumer consent provided?\", \"Client_ID\", \"Sub-product\"], \"callcenterlogs\": [\"Date received\", \"Complaint ID\", \"ser_time\", \"priority\", \"ser_start\", \"outcome\", \"phonefinal\", \"server\", \"ser_exit\", \"call_id\", \"type\", \"vru+line\"], \"client\": [\"day\", \"city\", \"year\", \"month\", \"district_id\", \"age\", \"state\", \"phone\", \"social\", \"address_1\", \"first\", \"address_2\"], \"district\": [\"city\", \"state_abbrev\", \"division\", \"district_id\"], \"reviews\": [\"Date\", \"district_id\", \"Reviews\", \"Product\"]}"
When did the earliest complaint start on 2017/3/22?
SELECT MIN(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22'
retail_complains
241
["client", "callcenterlogs", "state", "district", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"callcenterlogs\": [\"ser_start\", \"Complaint ID\", \"Date received\", \"ser_time\", \"priority\", \"type\", \"server\", \"phonefinal\", \"vru+line\", \"call_id\", \"outcome\"], \"events\": [\"Complaint ID\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Timely response?\", \"Date received\", \"Company response to consumer\", \"Consumer consent provided?\", \"Date sent to company\", \"Issue\", \"Sub-issue\", \"Submitted via\", \"Tags\", \"Product\", \"Client_ID\", \"Sub-product\"], \"district\": [\"city\", \"division\", \"state_abbrev\", \"district_id\"], \"client\": [\"city\", \"year\", \"first\", \"day\", \"district_id\", \"state\", \"month\", \"zipcode\", \"social\", \"age\", \"address_1\", \"address_2\", \"sex\", \"phone\"], \"state\": [\"Region\", \"State\", \"StateCode\"]}"
Which complaint is more urgent, complaint ID CR2400594 or ID CR2405641?
SELECT CASE WHEN SUM(CASE WHEN `Complaint ID` = 'CR2400594' THEN priority END) > SUM(CASE WHEN `Complaint ID` = 'CR2405641' THEN priority END) THEN 'CR2400594' ELSE 'CR2405641' END FROM callcenterlogs
retail_complains
242
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Complaint ID\", \"Consumer complaint narrative\", \"Timely response?\", \"Issue\", \"Consumer disputed?\", \"Date sent to company\", \"Company response to consumer\", \"Sub-issue\", \"Consumer consent provided?\", \"Date received\", \"Client_ID\", \"Product\", \"Sub-product\"], \"callcenterlogs\": [\"Complaint ID\", \"priority\", \"outcome\", \"Date received\", \"phonefinal\", \"type\", \"call_id\", \"ser_time\", \"server\", \"vru+line\", \"rand client\", \"ser_start\"], \"district\": [\"division\", \"city\", \"district_id\", \"state_abbrev\"], \"reviews\": [\"district_id\", \"Product\", \"Reviews\"], \"client\": [\"state\", \"day\", \"email\", \"phone\", \"first\", \"district_id\", \"age\", \"city\", \"client_id\", \"zipcode\", \"address_2\", \"sex\", \"address_1\", \"middle\", \"month\"]}"
Please list the full names of all the male clients born after the year 1990.
SELECT first, middle, last FROM client WHERE year > 1990
retail_complains
243
["client", "callcenterlogs", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"sex\", \"year\", \"social\", \"client_id\", \"age\", \"first\", \"last\", \"day\", \"middle\", \"state\", \"district_id\", \"address_2\", \"city\", \"address_1\", \"month\", \"zipcode\", \"email\", \"phone\"], \"events\": [\"Client_ID\", \"Consumer disputed?\", \"Consumer consent provided?\", \"Company response to consumer\", \"Consumer complaint narrative\", \"Complaint ID\", \"Submitted via\", \"Tags\", \"Date sent to company\", \"Timely response?\", \"Date received\", \"Sub-product\", \"Product\", \"Sub-issue\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"type\", \"Date received\", \"outcome\", \"server\", \"ser_time\", \"ser_start\", \"call_id\", \"vru+line\"], \"reviews\": [\"Stars\", \"Reviews\", \"Product\", \"district_id\", \"Date\"], \"district\": [\"city\", \"state_abbrev\", \"district_id\"]}"
How many complaints have the client Diesel Galloway filed?
SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway'
retail_complains
244
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"city\", \"social\", \"client_id\", \"first\", \"zipcode\", \"district_id\", \"email\", \"address_1\", \"sex\", \"state\", \"last\", \"middle\", \"address_2\", \"year\", \"day\", \"month\", \"phone\", \"age\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"server\", \"type\", \"ser_start\", \"phonefinal\", \"call_id\", \"ser_time\", \"outcome\", \"ser_exit\", \"vru+line\", \"Date received\"], \"events\": [\"Client_ID\", \"Consumer disputed?\", \"Consumer complaint narrative\", \"Complaint ID\", \"Company response to consumer\", \"Consumer consent provided?\", \"Timely response?\", \"Issue\"], \"district\": [\"city\", \"division\", \"district_id\", \"state_abbrev\"], \"reviews\": [\"district_id\", \"Reviews\", \"Stars\", \"Product\", \"Date\"]}"
What is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?
SELECT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway' AND T2.`Date received` = '2014-07-03'
retail_complains
245
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Product\", \"Sub-product\", \"Consumer disputed?\", \"Complaint ID\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Consumer consent provided?\", \"Client_ID\", \"Timely response?\", \"Date received\", \"Submitted via\", \"Date sent to company\", \"Issue\", \"Tags\"], \"reviews\": [\"Product\", \"district_id\"], \"callcenterlogs\": [\"Complaint ID\", \"server\", \"type\", \"ser_time\", \"Date received\", \"ser_start\", \"rand client\", \"vru+line\", \"phonefinal\", \"call_id\", \"ser_exit\", \"priority\"], \"client\": [\"city\", \"zipcode\", \"district_id\", \"state\", \"email\", \"sex\", \"social\", \"client_id\", \"address_1\", \"first\", \"address_2\", \"phone\", \"last\", \"middle\", \"year\"], \"district\": [\"city\", \"state_abbrev\", \"district_id\", \"division\"]}"
Was the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself?
SELECT CASE WHEN T2.`Consumer consent provided?` IN (NULL, 'N/A', 'Empty') THEN 'No' ELSE 'Yes' END FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Matthew' AND T1.last = 'Pierce' AND T2.`Date received` = '2016-10-28'
retail_complains
246
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Tags\", \"Complaint ID\", \"Consumer disputed?\", \"Consumer complaint narrative\", \"Timely response?\", \"Consumer consent provided?\", \"Submitted via\", \"Company response to consumer\", \"Date sent to company\", \"Issue\", \"Sub-issue\", \"Date received\", \"Client_ID\", \"Product\", \"Sub-product\"], \"callcenterlogs\": [\"Complaint ID\", \"Date received\", \"priority\", \"ser_time\", \"rand client\", \"server\"], \"district\": [\"city\", \"state_abbrev\", \"division\", \"district_id\"], \"client\": [\"city\", \"district_id\", \"social\", \"year\", \"email\", \"day\", \"state\", \"first\", \"client_id\", \"month\", \"age\", \"address_1\", \"zipcode\", \"sex\", \"phone\", \"last\", \"address_2\"], \"reviews\": [\"Date\", \"district_id\", \"Product\", \"Reviews\", \"Stars\"]}"
For how long was the complaint filed by Matthew Pierce on 2016/10/28 delayed?
SELECT 365 * (strftime('%Y', T2.`Date sent to company`) - strftime('%Y', T2.`Date received`)) + 30 * (strftime('%M', T2.`Date sent to company`) - strftime('%M', T2.`Date received`)) + (strftime('%d', T2.`Date sent to company`) - strftime('%d', T2.`Date received`)) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Matthew' AND T1.last = 'Pierce' AND T2.`Date received` = '2016-10-28'
retail_complains
247
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Complaint ID\", \"Timely response?\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Date sent to company\", \"Date received\", \"Company response to consumer\", \"Issue\", \"Submitted via\", \"Sub-issue\", \"Product\", \"Client_ID\", \"Consumer consent provided?\", \"Tags\", \"Sub-product\"], \"callcenterlogs\": [\"Complaint ID\", \"Date received\", \"ser_time\", \"priority\", \"server\", \"outcome\", \"type\", \"phonefinal\"], \"reviews\": [\"Date\", \"district_id\", \"Product\", \"Reviews\", \"Stars\"], \"district\": [\"city\", \"state_abbrev\", \"division\", \"district_id\"], \"state\": [\"Region\", \"State\", \"StateCode\"]}"
What is the full name of the client whose complaint on 2017/3/27 was received by MICHAL?
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.`Date received` = '2017-03-27' AND T2.server = 'MICHAL'
retail_complains
248
["client", "callcenterlogs", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"callcenterlogs\": [\"rand client\", \"Date received\", \"Complaint ID\", \"server\", \"priority\", \"type\", \"phonefinal\", \"ser_time\", \"ser_start\", \"vru+line\", \"outcome\", \"ser_exit\"], \"client\": [\"city\", \"client_id\", \"day\", \"first\", \"middle\", \"social\", \"email\", \"state\", \"phone\", \"last\", \"year\", \"zipcode\", \"month\", \"district_id\", \"sex\", \"address_1\", \"address_2\", \"age\"], \"events\": [\"Client_ID\", \"Date received\", \"Consumer disputed?\", \"Complaint ID\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Consumer consent provided?\", \"Timely response?\", \"Date sent to company\", \"Product\", \"Sub-issue\", \"Issue\", \"Sub-product\", \"Submitted via\", \"Tags\"], \"district\": [\"city\", \"state_abbrev\"], \"reviews\": [\"Date\", \"Product\"]}"
For how long did the complaint filed on 2017/3/27 by Rachel Hicks last?
SELECT T2.ser_time FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.first = 'Rachel' AND T1.last = 'Hicks' AND T2.`Date received` = '2017-03-27'
retail_complains
249
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Complaint ID\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Timely response?\", \"Company response to consumer\", \"Date received\", \"Date sent to company\", \"Consumer consent provided?\", \"Submitted via\", \"Issue\", \"Tags\", \"Sub-issue\", \"Product\", \"Client_ID\", \"Sub-product\"], \"callcenterlogs\": [\"Complaint ID\", \"Date received\", \"ser_time\", \"outcome\", \"type\", \"priority\", \"server\"], \"client\": [\"last\", \"year\", \"city\", \"district_id\", \"month\", \"day\", \"social\", \"sex\", \"age\", \"state\", \"zipcode\", \"address_1\", \"first\", \"address_2\", \"email\", \"middle\"], \"reviews\": [\"Date\", \"district_id\", \"Reviews\", \"Product\", \"Stars\"], \"district\": [\"state_abbrev\", \"city\", \"division\", \"district_id\"]}"
Among all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?
SELECT COUNT(T2.Issue) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Issue = 'Deposits and withdrawals' AND T1.city = 'New York City'
retail_complains
250
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"city\", \"client_id\", \"day\", \"social\", \"district_id\", \"year\", \"first\", \"address_1\", \"state\", \"last\", \"sex\", \"middle\", \"address_2\", \"phone\", \"zipcode\", \"month\", \"age\", \"email\"], \"events\": [\"Issue\", \"Client_ID\", \"Sub-issue\", \"Complaint ID\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Company response to consumer\", \"Consumer consent provided?\", \"Submitted via\", \"Date sent to company\", \"Timely response?\", \"Date received\", \"Product\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"phonefinal\", \"Date received\", \"type\", \"vru+line\", \"call_id\"], \"district\": [\"city\", \"division\", \"state_abbrev\", \"district_id\"], \"reviews\": [\"district_id\", \"Reviews\", \"Stars\", \"Date\", \"Product\"]}"
Please list the full names of all the clients whose complaints are still in progress.
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Company response to consumer` = 'In progress'
retail_complains
251
["client", "callcenterlogs", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"day\", \"client_id\", \"social\", \"last\", \"first\", \"city\", \"state\", \"year\", \"district_id\", \"middle\", \"sex\", \"address_1\", \"address_2\", \"email\", \"age\", \"month\", \"phone\", \"zipcode\"], \"events\": [\"Client_ID\", \"Consumer disputed?\", \"Consumer complaint narrative\", \"Complaint ID\", \"Company response to consumer\", \"Timely response?\", \"Consumer consent provided?\", \"Issue\", \"Tags\", \"Submitted via\", \"Product\", \"Date received\", \"Date sent to company\", \"Sub-product\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"outcome\", \"server\", \"Date received\", \"ser_time\", \"ser_start\", \"type\", \"phonefinal\"], \"reviews\": [\"Stars\", \"Reviews\", \"Product\", \"district_id\", \"Date\"], \"district\": [\"city\", \"division\"]}"
Among the clients who did receive a timely response for their complaint, how many of them are from New York?
SELECT COUNT(T1.city) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Timely response?` = 'No' AND T1.city = 'New York City'
retail_complains
252
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Timely response?\", \"Company response to consumer\", \"Client_ID\", \"Date received\", \"Consumer complaint narrative\", \"Complaint ID\", \"Consumer disputed?\", \"Date sent to company\", \"Consumer consent provided?\", \"Submitted via\", \"Tags\", \"Sub-issue\", \"Issue\", \"Product\", \"Sub-product\"], \"client\": [\"city\", \"day\", \"social\", \"client_id\", \"first\", \"district_id\", \"state\", \"phone\", \"address_1\", \"year\", \"email\", \"middle\", \"sex\", \"last\", \"age\", \"zipcode\", \"address_2\", \"month\"], \"callcenterlogs\": [\"rand client\", \"Date received\", \"Complaint ID\", \"ser_time\", \"outcome\", \"phonefinal\"], \"reviews\": [\"Date\", \"Reviews\", \"district_id\", \"Stars\", \"Product\"], \"district\": [\"city\", \"division\", \"state_abbrev\", \"district_id\"]}"
How many complaints on credit cards in the year 2016 were filed by male clients?
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) = '2016' AND T1.sex = 'Male' AND T2.Product = 'Credit card'
retail_complains
253
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"year\", \"sex\", \"social\", \"client_id\", \"age\", \"first\", \"state\", \"city\", \"address_1\", \"last\", \"middle\", \"day\", \"address_2\", \"month\", \"district_id\", \"email\", \"zipcode\", \"phone\"], \"events\": [\"Client_ID\", \"Consumer disputed?\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Complaint ID\", \"Consumer consent provided?\", \"Submitted via\", \"Issue\", \"Date sent to company\", \"Date received\", \"Product\", \"Sub-product\", \"Sub-issue\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"Date received\", \"type\", \"phonefinal\", \"outcome\", \"server\", \"call_id\"], \"reviews\": [\"Date\", \"Product\", \"Reviews\", \"district_id\", \"Stars\"], \"district\": [\"city\", \"division\", \"state_abbrev\"]}"
Which division is Diesel Galloway in?
SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.first = 'Diesel' AND T1.last = 'Galloway'
retail_complains
254
["client", "callcenterlogs", "state", "district", "reviews"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"district\": [\"division\", \"district_id\", \"state_abbrev\", \"city\"], \"state\": [\"Region\", \"State\", \"StateCode\"], \"client\": [\"district_id\", \"zipcode\", \"city\", \"state\", \"middle\", \"client_id\", \"address_1\", \"year\", \"address_2\", \"month\", \"sex\", \"first\", \"social\"], \"callcenterlogs\": [\"server\", \"priority\", \"ser_start\", \"ser_exit\", \"vru+line\", \"Complaint ID\", \"rand client\", \"ser_time\", \"call_id\", \"type\", \"outcome\", \"phonefinal\", \"Date received\"], \"reviews\": [\"district_id\", \"Reviews\", \"Stars\", \"Product\", \"Date\"]}"
Please list the full names of all the male clients in the Pacific division.
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific' AND T1.sex = 'Male'
retail_complains
255
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"district\": [\"division\", \"state_abbrev\", \"city\", \"district_id\"], \"client\": [\"sex\", \"client_id\", \"social\", \"city\", \"middle\", \"state\", \"district_id\", \"last\", \"day\", \"first\", \"zipcode\", \"year\", \"address_1\", \"age\", \"address_2\", \"email\", \"phone\", \"month\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"server\", \"ser_start\", \"type\", \"vru+line\", \"call_id\", \"priority\", \"ser_time\", \"outcome\", \"phonefinal\", \"ser_exit\", \"Date received\"], \"events\": [\"Client_ID\", \"Consumer disputed?\", \"Consumer consent provided?\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Sub-issue\", \"Tags\", \"Timely response?\", \"Complaint ID\", \"Sub-product\", \"Date received\", \"Date sent to company\"], \"state\": [\"Region\"]}"
What is the average number of complaints on credit cards filed by clients from New York in the 3 consecutive years starting from 2015?
SELECT CAST(COUNT(T2.`Complaint ID`) AS REAL) / 3 AS average FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE strftime('%Y', T2.`Date received`) BETWEEN '2015' AND '2017' AND T1.city = 'New York City' AND T2.Product = 'Credit card'
retail_complains
256
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"year\", \"city\", \"client_id\", \"social\", \"age\", \"zipcode\", \"district_id\", \"last\", \"phone\", \"first\", \"state\", \"address_1\", \"day\", \"middle\", \"sex\", \"address_2\", \"email\", \"month\"], \"events\": [\"Client_ID\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Complaint ID\", \"Company response to consumer\", \"Consumer consent provided?\", \"Submitted via\", \"Date sent to company\", \"Date received\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"phonefinal\", \"vru+line\", \"Date received\", \"ser_start\", \"type\", \"call_id\", \"server\", \"outcome\", \"priority\"], \"district\": [\"city\", \"division\", \"state_abbrev\", \"district_id\"], \"reviews\": [\"district_id\", \"Date\", \"Reviews\", \"Stars\", \"Product\"]}"
What is the percentage of the increase of complaints filed by the clients from New York from the year 2016 to the year 2017?
SELECT 100.0 * (SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2017' THEN 1 ELSE 0 END) - SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END)) / SUM(CASE WHEN strftime('%Y', T2.`Date received`) = '2016' THEN 1 ELSE 0 END) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City'
retail_complains
257
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"client\": [\"year\", \"city\", \"social\", \"day\", \"state\", \"client_id\", \"age\", \"sex\", \"first\", \"district_id\", \"address_1\", \"month\", \"email\", \"zipcode\", \"middle\", \"last\", \"address_2\", \"phone\"], \"events\": [\"Client_ID\", \"Complaint ID\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Consumer disputed?\", \"Date sent to company\", \"Date received\", \"Submitted via\", \"Issue\", \"Timely response?\", \"Sub-issue\", \"Product\", \"Consumer consent provided?\", \"Tags\", \"Sub-product\"], \"callcenterlogs\": [\"rand client\", \"Complaint ID\", \"Date received\", \"priority\", \"outcome\", \"type\"], \"reviews\": [\"Date\", \"district_id\", \"Reviews\", \"Product\", \"Stars\"], \"district\": [\"city\", \"division\", \"state_abbrev\", \"district_id\"]}"
What was the serve time for the complaint call from client "C00007127" on 2017/2/22?
SELECT T1.ser_time FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.Client_ID = 'C00007127' AND T1.`Date received` = '2017-02-22'
retail_complains
258
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"callcenterlogs\": [\"ser_time\", \"rand client\", \"Date received\", \"Complaint ID\", \"server\", \"priority\", \"phonefinal\", \"ser_start\", \"outcome\", \"call_id\", \"ser_exit\", \"type\", \"vru+line\"], \"client\": [\"day\", \"month\", \"phone\", \"city\", \"address_2\", \"state\", \"year\", \"social\", \"sex\", \"first\", \"client_id\", \"zipcode\", \"age\", \"last\", \"district_id\", \"address_1\", \"middle\", \"email\"], \"events\": [\"Client_ID\", \"Timely response?\", \"Complaint ID\", \"Consumer disputed?\", \"Consumer complaint narrative\", \"Date received\", \"Company response to consumer\", \"Date sent to company\", \"Consumer consent provided?\", \"Tags\", \"Issue\", \"Submitted via\", \"Product\"], \"district\": [\"division\", \"city\", \"state_abbrev\", \"district_id\"], \"reviews\": [\"Date\", \"Stars\"]}"
Which state does the owner of "[email protected]" live in? Give the full name of the state.
SELECT T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.email = '[email protected]'
retail_complains
259
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"state\": [\"Region\", \"State\", \"StateCode\"], \"district\": [\"state_abbrev\", \"city\", \"district_id\", \"division\"], \"client\": [\"state\", \"email\", \"city\", \"social\", \"district_id\", \"phone\", \"last\", \"client_id\", \"address_1\", \"first\", \"year\", \"day\", \"middle\", \"sex\", \"address_2\"], \"events\": [\"Consumer disputed?\", \"Consumer consent provided?\", \"Timely response?\", \"Company response to consumer\", \"Date sent to company\", \"Date received\", \"Client_ID\", \"Consumer complaint narrative\", \"Complaint ID\", \"Submitted via\", \"Sub-product\", \"Product\"], \"reviews\": [\"Reviews\", \"district_id\", \"Product\", \"Stars\", \"Date\"]}"
Which detailed product did Mr Lennox Oliver Drake complain about?
SELECT DISTINCT T2.`Sub-product` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Lennox' AND T1.middle = 'Oliver' AND T1.last = 'Drake' AND T1.sex = 'Male'
retail_complains
260
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Product\", \"Sub-product\", \"Consumer disputed?\", \"Company response to consumer\", \"Consumer complaint narrative\", \"Client_ID\", \"Consumer consent provided?\", \"Timely response?\", \"Complaint ID\", \"Issue\", \"Sub-issue\", \"Tags\", \"Date sent to company\"], \"reviews\": [\"Product\", \"Date\", \"Reviews\", \"Stars\", \"district_id\"], \"callcenterlogs\": [\"server\", \"rand client\", \"priority\", \"ser_time\", \"type\", \"vru+line\", \"call_id\", \"outcome\", \"ser_start\", \"Date received\", \"phonefinal\", \"Complaint ID\", \"ser_exit\"], \"client\": [\"first\", \"year\", \"day\", \"sex\", \"email\", \"client_id\", \"age\", \"city\", \"month\", \"middle\", \"social\", \"address_1\", \"zipcode\", \"last\", \"phone\"], \"state\": [\"StateCode\", \"Region\", \"State\"]}"
What was the detailed issue did Mr Gunner Omer Fuller complain about?
SELECT T2.`Sub-issue` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Gunner' AND T1.middle = 'Omer' AND T1.last = 'Fuller' AND T1.sex = 'Male'
retail_complains
261
["client", "callcenterlogs", "state", "district", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Issue\", \"Sub-issue\", \"Consumer disputed?\", \"Complaint ID\", \"Consumer complaint narrative\", \"Client_ID\", \"Tags\", \"Timely response?\", \"Company response to consumer\", \"Product\", \"Sub-product\", \"Submitted via\"], \"callcenterlogs\": [\"priority\", \"server\", \"ser_start\", \"type\", \"Complaint ID\", \"ser_time\", \"call_id\", \"Date received\", \"ser_exit\", \"outcome\", \"rand client\", \"phonefinal\", \"vru+line\"], \"client\": [\"middle\", \"first\", \"city\", \"social\", \"age\", \"month\", \"year\", \"day\", \"zipcode\", \"district_id\", \"sex\", \"state\", \"client_id\", \"address_1\", \"email\", \"last\"], \"district\": [\"city\", \"division\", \"district_id\", \"state_abbrev\"], \"state\": [\"State\", \"Region\", \"StateCode\"]}"
Did Ms. Lyric Emely Taylor provide the consent for result of the complaint call on 2016/5/20?
SELECT CASE WHEN T2.`Consumer consent provided?` IN (NULL, 'N/A', '') THEN 'No' ELSE 'Yes' END FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Lyric' AND T1.middle = 'Emely' AND T1.last = 'Taylor' AND T1.sex = 'Female' AND T2.`Date received` = '2016-05-20'
retail_complains
262
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"events\": [\"Consumer consent provided?\", \"Complaint ID\", \"Consumer complaint narrative\", \"Consumer disputed?\", \"Timely response?\", \"Company response to consumer\", \"Submitted via\", \"Date received\", \"Date sent to company\"], \"callcenterlogs\": [\"Complaint ID\", \"Date received\", \"outcome\", \"call_id\", \"phonefinal\", \"rand client\", \"ser_time\", \"type\", \"server\", \"priority\", \"ser_start\", \"vru+line\", \"ser_exit\"], \"reviews\": [\"Date\", \"district_id\", \"Stars\", \"Reviews\", \"Product\"], \"client\": [\"sex\", \"city\", \"phone\", \"email\", \"social\", \"district_id\", \"zipcode\", \"day\", \"address_1\", \"month\", \"state\", \"first\", \"age\", \"address_2\", \"year\", \"client_id\", \"last\"], \"district\": [\"city\", \"division\", \"district_id\", \"state_abbrev\"]}"
How many days delay for the complaint call from Mr. Brantley Julian Stanley on 2012/5/18?
SELECT 365 * (strftime('%Y', T2.`Date sent to company`) - strftime('%Y', T2.`Date received`)) + 30 * (strftime('%M', T2.`Date sent to company`) - strftime('%M', T2.`Date received`)) + (strftime('%d', T2.`Date sent to company`) - strftime('%d', T2.`Date received`)) AS days FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2012-05-18' AND T1.sex = 'Male' AND T1.first = 'Brantley' AND T1.middle = 'Julian' AND T1.last = 'Stanley'
retail_complains
263
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"callcenterlogs\": [\"Date received\", \"Complaint ID\", \"ser_time\", \"priority\", \"call_id\", \"phonefinal\", \"outcome\", \"type\", \"vru+line\", \"ser_start\", \"server\", \"rand client\", \"ser_exit\"], \"events\": [\"Timely response?\", \"Complaint ID\", \"Date received\", \"Consumer complaint narrative\", \"Date sent to company\", \"Consumer disputed?\", \"Company response to consumer\", \"Issue\", \"Sub-issue\", \"Consumer consent provided?\", \"Submitted via\", \"Tags\", \"Client_ID\", \"Product\", \"Sub-product\"], \"client\": [\"day\", \"phone\", \"district_id\", \"city\", \"month\", \"email\", \"zipcode\", \"first\", \"social\", \"address_1\", \"year\"], \"reviews\": [\"Date\", \"district_id\", \"Reviews\", \"Product\", \"Stars\"], \"district\": [\"division\", \"city\", \"district_id\", \"state_abbrev\"]}"
Which district did the review on 2018/9/11 come from? Give the name of the city.
SELECT T2.district_id, T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Date = '2018-09-11'
retail_complains
264
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"reviews\": [\"district_id\", \"Reviews\", \"Date\", \"Stars\", \"Product\"], \"district\": [\"city\", \"district_id\", \"division\", \"state_abbrev\"], \"client\": [\"district_id\", \"city\", \"day\", \"phone\", \"middle\", \"year\", \"social\", \"last\", \"first\", \"sex\"], \"events\": [\"Timely response?\", \"Consumer disputed?\", \"Submitted via\", \"Complaint ID\", \"Date received\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Consumer consent provided?\", \"Sub-issue\", \"Date sent to company\", \"Issue\", \"Tags\", \"Product\", \"Sub-product\", \"Client_ID\"], \"callcenterlogs\": [\"Date received\", \"priority\", \"Complaint ID\", \"vru+line\", \"outcome\", \"rand client\", \"call_id\", \"phonefinal\", \"server\", \"ser_time\", \"type\", \"ser_start\", \"ser_exit\"]}"
What was the review context from Jacksonville on 2017/7/22?
SELECT T1.Reviews FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Jacksonville' AND T1.Date = '2017-07-22'
retail_complains
265
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"reviews\": [\"Reviews\", \"Date\", \"district_id\", \"Stars\", \"Product\"], \"events\": [\"Timely response?\", \"Consumer disputed?\", \"Submitted via\", \"Date received\", \"Complaint ID\", \"Consumer complaint narrative\", \"Company response to consumer\", \"Date sent to company\", \"Tags\", \"Issue\", \"Consumer consent provided?\", \"Client_ID\", \"Sub-issue\", \"Product\", \"Sub-product\"], \"callcenterlogs\": [\"Date received\", \"priority\", \"ser_time\", \"outcome\", \"server\", \"Complaint ID\", \"ser_start\", \"ser_exit\", \"call_id\", \"type\", \"vru+line\", \"phonefinal\", \"rand client\"], \"district\": [\"city\", \"state_abbrev\", \"division\", \"district_id\"], \"client\": [\"city\", \"day\", \"social\", \"zipcode\", \"age\", \"month\", \"district_id\", \"state\", \"email\", \"middle\"]}"
Which product received a review from Indianapolis on 2016/10/7?
SELECT T1.Product FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Indianapolis' AND T1.Date = '2016-10-07'
retail_complains
266
["client", "callcenterlogs", "state", "district", "reviews", "events"]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
[ [ " CREATE TABLE callcenterlogs ( \"Date received\" DATE, \"Complaint ID\" TEXT, \"rand client\" TEXT, phonefinal TEXT, \"vru+line\" TEXT, call_id INTEGER, priority INTEGER, type TEXT, outcome TEXT, server TEXT, ser_start TEXT, ser_exit TEXT, ser_time TEXT, PRIMARY KEY (\"Complaint ID\"), FOREIGN KEY(\"rand client\") REFERENCES client (client_id) ) ", " CREATE TABLE client ( client_id TEXT, sex TEXT, day INTEGER, month INTEGER, year INTEGER, age INTEGER, social TEXT, first TEXT, middle TEXT, last TEXT, phone TEXT, email TEXT, address_1 TEXT, address_2 TEXT, city TEXT, state TEXT, zipcode INTEGER, district_id INTEGER, PRIMARY KEY (client_id), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE district ( district_id INTEGER, city TEXT, state_abbrev TEXT, division TEXT, PRIMARY KEY (district_id), FOREIGN KEY(state_abbrev) REFERENCES state (\"StateCode\") ) ", " CREATE TABLE events ( \"Date received\" DATE, \"Product\" TEXT, \"Sub-product\" TEXT, \"Issue\" TEXT, \"Sub-issue\" TEXT, \"Consumer complaint narrative\" TEXT, \"Tags\" TEXT, \"Consumer consent provided?\" TEXT, \"Submitted via\" TEXT, \"Date sent to company\" TEXT, \"Company response to consumer\" TEXT, \"Timely response?\" TEXT, \"Consumer disputed?\" TEXT, \"Complaint ID\" TEXT, \"Client_ID\" TEXT, PRIMARY KEY (\"Complaint ID\", \"Client_ID\"), FOREIGN KEY(\"Complaint ID\") REFERENCES callcenterlogs (\"Complaint ID\"), FOREIGN KEY(\"Client_ID\") REFERENCES client (client_id) ) ", " CREATE TABLE reviews ( \"Date\" DATE, \"Stars\" INTEGER, \"Reviews\" TEXT, \"Product\" TEXT, district_id INTEGER, PRIMARY KEY (\"Date\"), FOREIGN KEY(district_id) REFERENCES district (district_id) ) ", " CREATE TABLE state ( \"StateCode\" TEXT, \"State\" TEXT, \"Region\" TEXT, PRIMARY KEY (\"StateCode\") ) " ] ]
6
6
"{\"reviews\": [\"Product\", \"Reviews\", \"Date\", \"district_id\", \"Stars\"], \"events\": [\"Product\", \"Sub-product\", \"Date received\", \"Company response to consumer\", \"Consumer disputed?\", \"Timely response?\", \"Consumer consent provided?\", \"Submitted via\", \"Date sent to company\", \"Consumer complaint narrative\", \"Sub-issue\", \"Issue\", \"Complaint ID\", \"Client_ID\", \"Tags\"], \"callcenterlogs\": [\"Date received\", \"server\", \"outcome\", \"vru+line\", \"priority\", \"ser_time\", \"rand client\", \"Complaint ID\", \"ser_exit\", \"phonefinal\", \"type\"], \"client\": [\"city\", \"zipcode\", \"email\", \"state\", \"age\", \"year\", \"day\", \"month\", \"address_1\", \"sex\", \"phone\", \"address_2\", \"client_id\", \"district_id\"], \"district\": [\"state_abbrev\", \"city\"]}"