1sf/bird-sql-train-with-schema huggingface dataset:
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Which titles has above average royalty rate? Give those title's name, type and price?
Evidence: average royalty rate = DIVIDE(SUM(royalty), COUNT(title_id))
SQL: 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 )
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: In 1994 which title had less order quanty than the average order quantity? Find the title name, type and price.
Evidence: orders in 1994 refers to YEAR(ord_date) = 1994; order quantity refers to number of order expressed by ord_num; average order quantity = DIVIDE(SUM(ord_num), COUNT(title_id))
SQL: 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 )
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.
Evidence: Eric the Read Books is a publisher which refers to pub_name;
SQL: 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
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.
Evidence: US publisher refers publisher in the US where country = 'USA';
SQL: 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
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Find the difference between the average royalty of titles published by US and non US publishers?
Evidence: US publisher refers publisher in the US where country = 'USA'; non-US publishers refers publisher not in the US where country! = 'USA'; difference = SUBTRACT(AVG(royalty) where country = 'USA', AVG(royalty) where country! = 'USA'))
SQL: 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
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Calculate the average level difference between the Marketing editors hired by the US and non-US publishers?
Evidence: Marketing manager is a job description which refers to job_desc; US publisher refers publisher in the US where country = 'USA'; non-US publishers refers publisher not in the US where country! = 'USA'; job level refers to job_lvl; average level = AVG(job_lvl)
SQL: 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'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: 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?
Evidence: publisher refers to pub_name; about the title refers to notes
SQL: 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.'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: 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?
Evidence: year to date sales refers to ytd_sales; about the title refers to notes
SQL: 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.'
Database: book_publishing_company
Tables: authors, jobs, publishers, employee, pub_info, stores, discounts, titles, roysched, sales, titleauthor
Columns (table index, column name): -1, *, 0, au_id, 0, au_lname, 0, au_fname, 0, phone, 0, address, 0, city, 0, state, 0, zip, 0, contract, 1, job_id, 1, job_desc, 1, min_lvl, 1, max_lvl, 2, pub_id, 2, pub_name, 2, city, 2, state, 2, country, 3, emp_id, 3, fname, 3, minit, 3, lname, 3, job_id, 3, job_lvl, 3, pub_id, 3, hire_date, 4, pub_id, 4, logo, 4, pr_info, 5, stor_id, 5, stor_name, 5, stor_address, 5, city, 5, state, 5, zip, 6, discounttype, 6, stor_id, 6, lowqty, 6, highqty, 6, discount, 7, title_id, 7, title, 7, type, 7, pub_id, 7, price, 7, advance, 7, royalty, 7, ytd_sales, 7, notes, 7, pubdate, 8, title_id, 8, lorange, 8, hirange, 8, royalty, 9, stor_id, 9, ord_num, 9, ord_date, 9, qty, 9, payterms, 9, title_id, 10, au_id, 10, title_id, 10, au_ord, 10, royaltyper
Question: Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores?
Evidence: qty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA"
SQL: 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
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: On which day was the most verbose complaint received?
Evidence: day received refers to "Date received"; most verbose complaint refers to MAX(ser_time);
SQL: SELECT `Date received` FROM callcenterlogs WHERE ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: When did the earliest complaint start on 2017/3/22?
Evidence: earliest complaint refers to oldest ser_start; on 2017/3/22 refers to "Date received" = '2017-03-22';
SQL: SELECT MIN(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: Which complaint is more urgent, complaint ID CR2400594 or ID CR2405641?
Evidence: more urgent refers to MAX(priority);
SQL: 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
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: Please list the full names of all the male clients born after the year 1990.
Evidence: full names = first, middle, last; male refers to sex = 'Male'; year > 1990;
SQL: SELECT first, middle, last FROM client WHERE year > 1990
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: How many complaints have the client Diesel Galloway filed?
SQL: 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'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: What is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?
Evidence: detailed product refers to "sub-product"; on 2014/7/3 refers to "Date received" = '2014-07-03';
SQL: 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'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: Was the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself?
Evidence: on 2016/10/28 refers to Date received = '2016-10-28'; "Consumer consent provided?" in (null, 'N/A', 'Empty') means that the company didn't get the permission of consent; "Consumer consent provided?" not in (null, 'N/A', 'Empty') means that customers provide the consent for this tag;
SQL: 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'
Database: retail_complains
Tables: state, callcenterlogs, client, district, events, reviews
Columns (table index, column name): -1, *, 0, StateCode, 0, State, 0, Region, 1, Date received, 1, Complaint ID, 1, rand client, 1, phonefinal, 1, vru+line, 1, call_id, 1, priority, 1, type, 1, outcome, 1, server, 1, ser_start, 1, ser_exit, 1, ser_time, 2, client_id, 2, sex, 2, day, 2, month, 2, year, 2, age, 2, social, 2, first, 2, middle, 2, last, 2, phone, 2, email, 2, address_1, 2, address_2, 2, city, 2, state, 2, zipcode, 2, district_id, 3, district_id, 3, city, 3, state_abbrev, 3, division, 4, Date received, 4, Product, 4, Sub-product, 4, Issue, 4, Sub-issue, 4, Consumer complaint narrative, 4, Tags, 4, Consumer consent provided?, 4, Submitted via, 4, Date sent to company, 4, Company response to consumer, 4, Timely response?, 4, Consumer disputed?, 4, Complaint ID, 4, Client_ID, 5, Date, 5, Stars, 5, Reviews, 5, Product, 5, district_id
Question: For how long was the complaint filed by Matthew Pierce on 2016/10/28 delayed?
Evidence: on 2016/10/28 refers to "Date received" = '2016-10-28'; delayed = SUBTRACT("Date sent to company', 'Date received");
SQL: 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'