db_id
stringclasses
69 values
question
stringlengths
24
325
evidence
stringlengths
0
673
schema_text_wo_content
stringclasses
69 values
schema_text_with_content
stringclasses
69 values
ori_query
stringlengths
23
804
amb_query
stringlengths
23
804
book_publishing_company
Please list the first names of the employees who work as Managing Editor.
Managing Editor is a job description which refers to job_desc
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
What is the highest level of job to get to for the employee who got hired the earliest?
highest job level refers to MAX(job_lvl); hired the earliest refers to MIN(hire_date)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
In which city is the store with the highest total sales quantity located?
qty is abbreviation for quantity; highest sales quantity refers to MAX(qty)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
What is the price of the book that sells the best?
qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
Please list the stores that ordered the book "Life Without Fear".
store name refers to stor_name
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
Among the stores that have ordered the book "Life Without Fear", how many of them are located in Massachusetts?
Massachusetts is a state
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
In which country is the publisher of the book "Life Without Fear" located?
Life Without Fear is book title
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
What is the publisher that has published the most expensive book?
most expensive book refers to MAX(price)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
Among the publishers in the USA, how many of them have published books that are over $15?
are over $15 refers to price>15
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
Please give more detailed information about the first three books that sell the best.
qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
How many books on business have the bookstores in Massachusetts ordered?
Massachusetts is a state; business books refers to type = 'business'
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
What is the average quantity of each order for the book "Life Without Fear"?
qty is abbreviation for quantity; average quantity order = AVG(qty)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
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?
Managing Editor is a job description which refers to job_desc; job level refers to job_lvl; highest level job refers to max_lvl; levels between the average level and the highest level = SUBTRACT(max_lvl; AVG(job_lvl))
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
Which one is the cheapest business book?
business books refers to type = 'business'; cheapest book refers to MIN(price)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
SELECT title FROM titles WHERE type = 'business' ORDER BY price LIMIT 1
SELECT title FROM titles WHERE type = 'business' ORDER BY price LIMIT 1
book_publishing_company
Which type of book had the most pre-paid amount?
most pre-paid amount refers to MAX(advance)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
SELECT type FROM titles ORDER BY advance DESC LIMIT 1
SELECT type FROM titles ORDER BY advance DESC LIMIT 1
book_publishing_company
What's the royalty for the bestseller book?
qty is abbreviation for quantity; bestseller means with the most sales quantity; MAX(qty)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
SELECT royalty FROM titles ORDER BY ytd_sales DESC LIMIT 1
SELECT royalty FROM titles ORDER BY ytd_sales DESC LIMIT 1
book_publishing_company
Which job level is O'Rourke at?
job level refers to job_lvl
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'
SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'
book_publishing_company
Show me the employ id of the highest employee who doesn't have a middle name.
highest employee refers to employee with the highest job level; MAX(job_lvl)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1
SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1
book_publishing_company
Is the author of "Sushi, Anyone?" on the contract?
contract = 1 means on contract; contract = 0 means not on contract
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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?'
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
Which publisher had the highest job level? Give his/her full name.
highest job level refers to MAX(job_lvl)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
What's Pedro S Afonso's job title?
job title means job description which refers to job_desc
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
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?
max level for his position refers to max_lvl; job level refers to job_lvl; level left to reach the max = SUBTRACT(max_lvl, job_lvl)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
What's on the notes for the order happened on 1994/9/14?
order happened on refers to ord_date
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
List the type of the book for the order which was sold on 1993/5/29.
sold on refers to ord_date
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
Tell me about the information of the French publisher.
French publisher means publisher in France where country = 'France'
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
What's the publisher of the book "Silicon Valley Gastronomic Treats"? Give the publisher's name.
publisher name refers to pub_name; Silicon Valley Gastronomic Treats is the title of a book
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
Which city did Victoria P Ashworth work in?
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
How many sales did the store in Remulade make?
Remulade is a city; sales in the store refers to ord_num
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
For the quantities, what percent more did the store in Fremont sell than the store in Portland in 1993?
qty is abbreviation for quantity; Fremont and Portland are name of city; sell in 1993 refers to YEAR(ord_date) = 1993; percentage = DIVIDE( SUBTRACT(SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)), SUM(qty where city = ‘Portland’ and year(ord_date = 1993))), SUM(qty where city = ‘Fremont’ and year(ord_date = 1993)) *100
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
Among all the employees, how many percent more for the publishers than designers?
publisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer'))
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
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.
job level refers to job_lvl; YEAR(hire_date) between 1990 and 1995
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
SELECT fname, minit, lname FROM employee WHERE STRFTIME('%Y', hire_date) BETWEEN '1990' AND '1995' ORDER BY job_lvl DESC
SELECT fname, minit, lname FROM employee WHERE STRFTIME('%Y', hire_date) BETWEEN '1990' AND '1995' ORDER BY job_lvl DESC
book_publishing_company
Which titles has above average royalty rate? Give those title's name, type and price?
average royalty rate = DIVIDE(SUM(royalty), COUNT(title_id))
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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 )
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
In 1994 which title had less order quanty than the average order quantity? Find the title name, type and price.
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))
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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 )
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
List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.
Eric the Read Books is a publisher which refers to pub_name;
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.
US publisher refers publisher in the US where country = 'USA';
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
Find the difference between the average royalty of titles published by US and non US publishers?
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'))
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
Calculate the average level difference between the Marketing editors hired by the US and non-US publishers?
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)
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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'
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
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?
publisher refers to pub_name; about the title refers to notes
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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.'
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
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?
year to date sales refers to ytd_sales; about the title refers to notes
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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.'
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
Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores?
qty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA"
Table authors, columns = [`au_id` (author id), `au_lname` (author last name), `au_fname` (author first name), `phone` (phone), `address` (address), `city` (city), `state` (state), `zip` (zip), `contract` (contract)] Table jobs, columns = [`job_id` (job id), `job_desc` (job description), `min_lvl` (min level), `max_lvl` (max level)] Table publishers, columns = [`pub_id` (publisher id), `pub_name` (publisher name), `city` (city), `state` (state), `country` (country)] Table employee, columns = [`emp_id` (employee id), `fname` (first name), `minit` (minit), `lname` (last name), `job_id` (job id), `job_lvl` (job level), `pub_id` (publisher id), `hire_date` (hire_date)] Table pub_info, columns = [`pub_id` (publication id), `logo` (logo), `pr_info` (publisher's information)] Table stores, columns = [`stor_id` (store id), `stor_name` (store name), `stor_address` (store address), `city` (city), `state` (state), `zip` (zip)] Table discounts, columns = [`discounttype` (discount type), `stor_id` (store id), `lowqty` (low quantity), `highqty` (high quantity), `discount` (discount)] Table titles, columns = [`title_id` (title id), `title` (title), `type` (type), `pub_id` (publisher id), `price` (price), `advance` (advance), `royalty` (royalty), `ytd_sales` (year to date sales), `notes` (notes), `pubdate` (publication date)] Table roysched, columns = [`title_id` (title_id), `lorange` (low range), `hirange` (high range), `royalty` (royalty)] Table sales, columns = [`stor_id` (store id), `ord_num` (order number), `ord_date` (order date), `qty` (quantity), `payterms` (payterms), `title_id` (title id)] Table titleauthor, columns = [`au_id` (author id), `title_id` (title id), `au_ord` (author ordering), `royaltyper` (royaltyper)] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
Table authors, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `au_lname` (author last name. Example values: [White, Green, Carson]), `au_fname` (author first name. Example values: [Johnson, Marjorie, Cheryl]), `phone` (phone. Example values: [408 496-7223, 415 986-7020, 415 548-7723]), `address` (address. Example values: [10932 Bigge Rd., 309 63rd St. #411, 589 Darwin Ln.]), `city` (city. Example values: [Menlo Park, Oakland, Berkeley]), `state` (state. Example values: [CA, KS, TN]), `zip` (zip. Example values: [94025, 94618, 94705]), `contract` (contract. Example values: [0])] Table jobs, columns = [`job_id` (job id. Example values: [1, 2, 3]), `job_desc` (job description. Example values: [New Hire - Job not specified, Chief Executive Officer, Business Operations Manager]), `min_lvl` (min level. Example values: [10, 200, 175]), `max_lvl` (max level. Example values: [10, 250, 225])] Table publishers, columns = [`pub_id` (publisher id. Example values: [0736, 0877, 1389]), `pub_name` (publisher name. Example values: [New Moon Books, Binnet & Hardley, Algodata Infosystems]), `city` (city. Example values: [Boston, Washington, Berkeley]), `state` (state. Example values: [MA, DC, CA]), `country` (country. Example values: [USA, Germany, France])] Table employee, columns = [`emp_id` (employee id. Example values: [A-C71970F, A-R89858F, AMD15433F]), `fname` (first name. Example values: [Aria, Annette, Ann]), `minit` (minit. Example values: [, M, R]), `lname` (last name. Example values: [Cruz, Roulet, Devon]), `job_id` (job id. Example values: [10, 6, 3]), `job_lvl` (job level. Example values: [87, 152, 200]), `pub_id` (publisher id. Example values: [1389, 9999, 9952]), `hire_date` (hire_date. Example values: [1991-10-26 00:00:00.0, 1990-02-21 00:00:00.0, 1991-07-16 00:00:00.0])] Table pub_info, columns = [`pub_id` (publication id. Example values: [0877, 1389, 1622]), `logo` (logo. Example values: []), `pr_info` (publisher's information. Example values: [])] Table stores, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `stor_name` (store name. Example values: [Eric the Read Books, Barnum's, News & Brews]), `stor_address` (store address. Example values: [788 Catamaugus Ave., 567 Pasadena Ave., 577 First St.]), `city` (city. Example values: [Seattle, Tustin, Los Gatos]), `state` (state. Example values: [WA, CA, OR]), `zip` (zip. Example values: [98056, 92789, 96745])] Table discounts, columns = [`discounttype` (discount type. Example values: [Initial Customer, Volume Discount, Customer Discount]), `stor_id` (store id. Example values: [None, 8042]), `lowqty` (low quantity. Example values: [None, 100]), `highqty` (high quantity. Example values: [None, 1000]), `discount` (discount. Example values: [10.5, 6.7, 5.0])] Table titles, columns = [`title_id` (title id. Example values: [BU1032, BU1111, BU2075]), `title` (title. Example values: [The Busy Executive's Database Guide, Cooking with Computers: Surreptitious Balance Sheets, You Can Combat Computer Stress!]), `type` (type. Example values: [business, mod_cook, UNDECIDED]), `pub_id` (publisher id. Example values: [1389, 0736, 0877]), `price` (price. Example values: [19.99, 11.95, 2.99]), `advance` (advance. Example values: [5000.0, 10125.0, 0.0]), `royalty` (royalty. Example values: [10, 24, 12]), `ytd_sales` (year to date sales. Example values: [4095, 3876, 18722]), `notes` (notes. Example values: [Helpful hints on how to use your electronic resources to the best advantage.]), `pubdate` (publication date. Example values: [1991-06-12 00:00:00.0, 1991-06-09 00:00:00.0, 1991-06-30 00:00:00.0])] Table roysched, columns = [`title_id` (title_id. Example values: [BU1032, PC1035, BU2075]), `lorange` (low range. Example values: [0, 5001, 2001]), `hirange` (high range. Example values: [5000, 50000, 2000]), `royalty` (royalty. Example values: [10, 12, 14])] Table sales, columns = [`stor_id` (store id. Example values: [6380, 7066, 7067]), `ord_num` (order number. Example values: [6871, 722a, A2976]), `ord_date` (order date. Example values: [1994-09-14 00:00:00.0, 1994-09-13 00:00:00.0, 1993-05-24 00:00:00.0]), `qty` (quantity. Example values: [5, 3, 50]), `payterms` (payterms. Example values: [Net 60, Net 30, ON invoice]), `title_id` (title id. Example values: [BU1032, PS2091, PC8888])] Table titleauthor, columns = [`au_id` (author id. Example values: [172-32-1176, 213-46-8915, 238-95-7766]), `title_id` (title id. Example values: [PS3333, BU1032, BU2075]), `au_ord` (author ordering. Example values: [1, 2, 3]), `royaltyper` (royaltyper. Example values: [100, 40, 30])] foreign keys = [employee.pub_id = publishers.pub_id, employee.job_id = jobs.job_id, pub_info.pub_id = publishers.pub_id, discounts.stor_id = stores.stor_id, titles.pub_id = publishers.pub_id, roysched.title_id = titles.title_id, sales.title_id = titles.title_id, sales.stor_id = stores.stor_id, titleauthor.title_id = titles.title_id, titleauthor.au_id = authors.au_id]
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
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
retail_complains
On which day was the most verbose complaint received?
day received refers to "Date received"; most verbose complaint refers to MAX(ser_time);
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT `Date received` FROM callcenterlogs WHERE ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )
SELECT `Date received` FROM callcenterlogs WHERE ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )
retail_complains
When did the earliest complaint start on 2017/3/22?
earliest complaint refers to oldest ser_start; on 2017/3/22 refers to "Date received" = '2017-03-22';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT MIN(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22'
SELECT MIN(ser_time) FROM callcenterlogs WHERE `Date received` = '2017-03-22'
retail_complains
Which complaint is more urgent, complaint ID CR2400594 or ID CR2405641?
more urgent refers to MAX(priority);
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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
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
Please list the full names of all the male clients born after the year 1990.
full names = first, middle, last; male refers to sex = 'Male'; year > 1990;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT first, middle, last FROM client WHERE year > 1990
SELECT first, middle, last FROM client WHERE year > 1990
retail_complains
How many complaints have the client Diesel Galloway filed?
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?
detailed product refers to "sub-product"; on 2014/7/3 refers to "Date received" = '2014-07-03';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Was the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself?
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;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
For how long was the complaint filed by Matthew Pierce on 2016/10/28 delayed?
on 2016/10/28 refers to "Date received" = '2016-10-28'; delayed = SUBTRACT("Date sent to company', 'Date received");
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What is the full name of the client whose complaint on 2017/3/27 was received by MICHAL?
full names = first, middle, last; on 2017/3/27 refers to "Date received" = '2017-03-27'; MICHAL refers to server = 'MICHAL';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
For how long did the complaint filed on 2017/3/27 by Rachel Hicks last?
how long did the complaint filed last refers to ser_time; on 2017/3/27 refers to "Date received" = '2017-03-27';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Among all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Please list the full names of all the clients whose complaints are still in progress.
full name = first, middle, last; complaints are still in progress refers to "Company response to consumer" = 'In progress';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Among the clients who did receive a timely response for their complaint, how many of them are from New York?
did not receive a timely response refers to "Timely response?" = 'No'; New York refers to city = 'New York';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
How many complaints on credit cards in the year 2016 were filed by male clients?
credit cards refers to Product = 'Credit card'; 2016 refers to year(Date received) = 2016; male refers to sex = 'Male';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Which division is Diesel Galloway in?
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Please list the full names of all the male clients in the Pacific division.
full names = first, middle, last; male refers to sex = 'Male';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What is the average number of complaints on credit cards filed by clients from New York in the 3 consecutive years starting from 2015?
average = AVG(Complaint ID); credit cards refers to Product = 'Credit card'; New York refers to city = 'New York'; 3 consecutive years starting from 2015 refers to "Date received" BETWEEN 2015 AND 2017;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What is the percentage of the increase of complaints filed by the clients from New York from the year 2016 to the year 2017?
percentage of increase = MULTIPLY(DIVIDE(SUBTRACT(SUM(year("Date received") = 2017), SUM(year("Date received") = 2016)), SUM(year("Date received") = 2016)), 1.0); New York refers to city = 'New York'; year("Date received") BETWEEN 2016 AND 2017;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What was the serve time for the complaint call from client "C00007127" on 2017/2/22?
serve time refers to ser_time; longer ser_time means more verbose or longer complaint; on 2017/2/22 refers to "Date received" = '2017-02-22';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Which state does the owner of "[email protected]" live in? Give the full name of the state.
full name of the state refers to state_name;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.email = '[email protected]'
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
Which detailed product did Mr Lennox Oliver Drake complain about?
detailed product refers to "Sub-product"; Mr refers to sex = 'Male';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What was the detailed issue did Mr Gunner Omer Fuller complain about?
detailed issue refers to Sub-issue; Mr refers to sex = 'Male';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Did Ms. Lyric Emely Taylor provide the consent for result of the complaint call on 2016/5/20?
Ms refers to sex = 'Female'; "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 the customers provide the consent; on 2016/5/20 refers to Date received = '2016-05-20';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
How many days delay for the complaint call from Mr. Brantley Julian Stanley on 2012/5/18?
days delay for the complaint = SUBTRACT("date sent to company", "Date received"); Mr refers to sex = 'Male'; on 2012/5/18 refers to "Date received" = '2012-05-18';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Which district did the review on 2018/9/11 come from? Give the name of the city.
on 2018/9/11 refers to Date = '2017-07-22';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
What was the review context from Jacksonville on 2017/7/22?
Jacksonville refers to city = 'Jacksonville'; on 2017/7/22 refers to Date = '2017-07-22';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
Which product received a review from Indianapolis on 2016/10/7?
Indianapolis refers to state = 'Indianapolis'; on 2016/10/7 refers to Date = '2013-04-04';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
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'
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
How many stars did "Eagle Capital" received from Little Rock on 2013/4/4?
Eagle Capital refers to Product = 'Eagle Capital'; Little Rock is a city; on 2013/4/4 refers to Date = '2013-04-04';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T2.city = 'Little Rock' AND T1.Date = '2013-04-04'
SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T2.city = 'Little Rock' AND T1.Date = '2013-04-04'
retail_complains
For the client who made the complaint call "CR0217298", what was his/her birthday?
complaint call refers to Complaint ID; birthday = year, month, day;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.month, T1.day FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Complaint ID` = 'CR0217298'
SELECT T1.month, T1.day FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Complaint ID` = 'CR0217298'
retail_complains
What was the phone of number of the client who made the complaint call "CR0100432" ?
complaint call refers to Complaint ID;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Complaint ID` = 'CR0100432'
SELECT T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Complaint ID` = 'CR0100432'
retail_complains
For all the complaint callers on 2017/3/27, what percentage of the clients are females?
on 2017/3/27 refers to "Date received" = '2017-03-27'; percentage = MULTIPLY(DIVIDE(SUM(sex = 'Female' ), COUNT(client_id)), 1.0); females refers to sex = 'Female';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT CAST(SUM(CASE WHEN T1.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2017-03-27'
SELECT CAST(SUM(CASE WHEN T1.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2017-03-27'
retail_complains
What is the percentage of the complaint calls from Mr Mason Javen Lopez has got the consent provided by the customer?
percentage = MULTIPLY(DIVIDE(SUM("Consumer consent provided?" = 'Consent provided'), COUNT(client_id)), 1.0); Mr refers to sex = 'Male'; consent provided by the customer refers to "Consumer consent provided?" = 'Consent provided';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT CAST(SUM(CASE WHEN T2.`Consumer consent provided?` = 'Consent provided' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.`Consumer consent provided?`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Male' AND T1.first = 'Mason' AND T1.middle = 'Javen' AND T1.last = 'Lopez'
SELECT CAST(SUM(CASE WHEN T2.`Consumer consent provided?` = 'Consent provided' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.`Consumer consent provided?`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Male' AND T1.first = 'Mason' AND T1.middle = 'Javen' AND T1.last = 'Lopez'
retail_complains
How many priority urgent complaints were received in march of 2017? List the complaint ID of these complaints.
urgent complaints refers to priority = 2; march of 2017 refers to "Date received" BETWEEN '2017-01-01' AND '2017-01-31';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(`Complaint ID`) FROM callcenterlogs WHERE `Date received` LIKE '2017-01%' AND priority = ( SELECT MAX(priority) FROM callcenterlogs )
SELECT COUNT(`Complaint ID`) FROM callcenterlogs WHERE `Date received` LIKE '2017-01%' AND priority = ( SELECT MAX(priority) FROM callcenterlogs )
retail_complains
Please list the full name, date of birth, and email id of the elderly clients in descending order of age.
full name = first, middle, last; date of birth = year, month, day; elderly clients refers to age > 65;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT first, middle, last, year, month , day, email FROM client WHERE age > 65 ORDER BY age DESC
SELECT first, middle, last, year, month , day, email FROM client WHERE age > 65 ORDER BY age DESC
retail_complains
Which product got the most five stars, and how many?
most five stars refers to MAX(COUNT(stars = 5));
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T.Product, MAX(T.num) FROM ( SELECT Product, COUNT(Stars) AS num FROM reviews WHERE Stars = 5 GROUP BY Product ) T
SELECT T.Product, MAX(T.num) FROM ( SELECT Product, COUNT(Stars) AS num FROM reviews WHERE Stars = 5 GROUP BY Product ) T
retail_complains
List all the states in the South region.
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT state FROM state WHERE Region = 'South'
SELECT state FROM state WHERE Region = 'South'
retail_complains
What is the email id of clients whose calls were hung?
email id refers to email; calls were hung refers to outcome = 'Hang';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.outcome = 'HANG'
SELECT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.outcome = 'HANG'
retail_complains
Calculate the average age of clients from the Midwest region.
average age = AVG(age);
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T3.Region) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest'
SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T3.Region) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest'
retail_complains
List the full name and phone number of clients who submitted the complaint via fax.
full name = first, middle, last; submitted the complaint via fax refers to "Submitted via" = 'fax';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Submitted via` = 'Fax'
SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Submitted via` = 'Fax'
retail_complains
Find and list the names of districts which has below-average stars for Eagle Capital.
below average = AVG(stars) < Stars; Eagle Capital refers to Product = 'Eagle Capital';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T2.division FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T1.Stars > ( SELECT AVG(Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id )
SELECT T2.division FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T1.Stars > ( SELECT AVG(Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id )
retail_complains
In the calls from the mountain division, how many are from teenage clients?
teenage refers to age BETWEEN 12 AND 20;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T1.age) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.age BETWEEN 12 AND 20 AND T2.division = 'Mountain'
SELECT COUNT(T1.age) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.age BETWEEN 12 AND 20 AND T2.division = 'Mountain'
retail_complains
What is the number of complaints related to Credit cards came from female clients?
Credit cards refers to Product = 'Credit card'; female refers to sex = 'female';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T2.Product = 'Credit card'
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T2.Product = 'Credit card'
retail_complains
Among the clients born between 1980 and 2000, list the name of male clients who complained through referral.
born between 1980 and 2000 refers to year BETWEEN 1980 AND 2000; name = first, middle, last; male refers to sex = 'Male'; complained through refers to "Submitted via";
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year BETWEEN 1980 AND 2000 AND T1.sex = 'Male' AND T2.`Submitted via` = 'Referral'
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year BETWEEN 1980 AND 2000 AND T1.sex = 'Male' AND T2.`Submitted via` = 'Referral'
retail_complains
What is the medium through which most complaints are registered in Florida?
medium refers to "Submitted via"; most complaints refers to MAX(Complaint ID); Florida refers to state = 'florida';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T3.`Submitted via` FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.state = 'FL' GROUP BY T1.`Complaint ID` ORDER BY COUNT(T1.`Complaint ID`) DESC LIMIT 1
SELECT T3.`Submitted via` FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.state = 'FL' GROUP BY T1.`Complaint ID` ORDER BY COUNT(T1.`Complaint ID`) DESC LIMIT 1
retail_complains
Calculate the average number of complaints received from New Bedford each year which are closed with explanation.
average = AVG("Complaint ID"); New Bedford refers to city = 'New Bedford'; closed with explanation refers to Company response to consumer = 'Closed with explanation';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT STRFTIME('%Y', T3.`Date received`) , CAST(SUM(CASE WHEN T3.`Company response to consumer` = 'Closed with explanation' THEN 1 ELSE 0 END) AS REAL) / COUNT(T3.`Complaint ID`) AS average FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.city = 'New Bedford' GROUP BY strftime('%Y', T3.`Date received`)
SELECT STRFTIME('%Y', T3.`Date received`) , CAST(SUM(CASE WHEN T3.`Company response to consumer` = 'Closed with explanation' THEN 1 ELSE 0 END) AS REAL) / COUNT(T3.`Complaint ID`) AS average FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN events AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.city = 'New Bedford' GROUP BY strftime('%Y', T3.`Date received`)
retail_complains
What percentage of consumers from Houston disputed complaints?
percentage = MULTIPLY(DIVIDE(SUM("Consumer disputed?" = 'Yes' AND city = 'Houston'), COUNT(client_id)), 1.0); Houston refers to city = 'Houston';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT CAST(SUM(CASE WHEN T2.`Consumer disputed?` = 'Yes' AND T1.city = 'Houston' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID
SELECT CAST(SUM(CASE WHEN T2.`Consumer disputed?` = 'Yes' AND T1.city = 'Houston' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID
retail_complains
Find the number of service members who complained in Syracuse.
service members refers to client.client_id; Syracuse refers to city = 'Syracuse';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Servicemember' AND T1.city = 'Syracuse'
SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Servicemember' AND T1.city = 'Syracuse'
retail_complains
Among the calls from California, what percentage are priority 1?
California refers to state = 'California'; percentage = MULTIPLY(DIVIDE(SUM(priority = 1), COUNT("Complaint ID"), 1.0));
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT CAST(SUM(CASE WHEN T1.priority = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.priority) FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id INNER JOIN state AS T4 ON T3.state_abbrev = T4.StateCode WHERE T4.State = 'California'
SELECT CAST(SUM(CASE WHEN T1.priority = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.priority) FROM callcenterlogs AS T1 INNER JOIN client AS T2 ON T1.`rand client` = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id INNER JOIN state AS T4 ON T3.state_abbrev = T4.StateCode WHERE T4.State = 'California'
retail_complains
Calculate the difference in the average age of elderly and middle-aged clients in the Northeast region.
difference in the average = SUBTRACT(AVG(age BETWEEN 35 AND 55), AVG( age > 65)); elderly refers to age > 65; middle-aged refers to age BETWEEN 35 AND 55;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT (CAST(SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.age > 65 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END)) AS difference FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Northeast'
SELECT (CAST(SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.age > 65 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END)) AS difference FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Northeast'
retail_complains
List by their ID number the 3 longest complaints.
ID number refers to "Complaint ID"; longest complaints refers to MAX(ser_time);
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT `Complaint ID` FROM callcenterlogs ORDER BY ser_time DESC LIMIT 3
SELECT `Complaint ID` FROM callcenterlogs ORDER BY ser_time DESC LIMIT 3
retail_complains
How many clients have an email account other than gmail.com?
email account other than gmail.com refers to email not like '%@gmail.com';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com'
SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com'
retail_complains
Identify by their ID all clients who did not give their consent permission.
did not give their consent permission refers to Consumer consent provided is null, 'N/A', or empty;
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT Client_ID FROM events WHERE `Consumer consent provided?` = 'N/A' OR 'Consumer consent provided?' IS NULL OR 'Consumer consent provided?' = ''
SELECT Client_ID FROM events WHERE `Consumer consent provided?` = 'N/A' OR 'Consumer consent provided?' IS NULL OR 'Consumer consent provided?' = ''
retail_complains
List by their ID the complaints received by the company on 25/09/2014 that took the longest.
ID of the complaints refers to "Complaint ID"; on 25/09/2014 refers to "Date sent to company" = '2014-09-25'; took the longest = MAX(SUBTRACT("Date sent to company", "Date received"));
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT `Complaint ID` FROM events WHERE strftime('%J', `Date sent to company`) - strftime('%J', `Date received`) = ( SELECT MAX(strftime('%J', `Date sent to company`) - strftime('%J', `Date received`)) FROM events WHERE `Date sent to company` = '2014-09-25' ) AND `Date sent to company` = '2014-09-25'
SELECT `Complaint ID` FROM events WHERE strftime('%J', `Date sent to company`) - strftime('%J', `Date received`) = ( SELECT MAX(strftime('%J', `Date sent to company`) - strftime('%J', `Date received`)) FROM events WHERE `Date sent to company` = '2014-09-25' ) AND `Date sent to company` = '2014-09-25'
retail_complains
List priority 2 complaints by date received.
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT DISTINCT `Complaint ID` FROM callcenterlogs WHERE priority = 2 ORDER BY `Date received` DESC
SELECT DISTINCT `Complaint ID` FROM callcenterlogs WHERE priority = 2 ORDER BY `Date received` DESC
retail_complains
How many complaints are not in process with an agent?
not in process with an agent refers to outcome ! = 'AGENT';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'
SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'
retail_complains
How many Credit Card complaints did Sharon handle?
Credit Card refers to Product = 'Credit Card'; Sharon refers to server = 'SHARON';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.Product = 'Credit card' AND T1.server = 'SHARON'
SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.Product = 'Credit card' AND T1.server = 'SHARON'
retail_complains
In which region have the most 1-star reviews been done?
most 1-star reviews refers to MAX(COUNT(stars = 1));
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T3.Region FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T1.Stars = 1 GROUP BY T3.Region ORDER BY COUNT(T3.Region) DESC LIMIT 1
SELECT T3.Region FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T1.Stars = 1 GROUP BY T3.Region ORDER BY COUNT(T3.Region) DESC LIMIT 1
retail_complains
In what years were the clients who demanded more problems with Certificate of deposit born?
more problems with Certificate refers to MAX(COUNT("Sub-product" = '(CD) Certificate of deposit'));
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT T1.year FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Sub-product` = '(CD) Certificate of deposit' GROUP BY T1.year ORDER BY COUNT(T1.year) DESC LIMIT 1
SELECT T1.year FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Sub-product` = '(CD) Certificate of deposit' GROUP BY T1.year ORDER BY COUNT(T1.year) DESC LIMIT 1
retail_complains
How many cases of billing dispute issues occurred in the Mountain division?
billing dispute refers to issue = 'Billing disputes';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T1.Issue) FROM events AS T1 INNER JOIN client AS T2 ON T1.Client_ID = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id WHERE T1.Issue = 'Billing disputes' AND T3.division = 'Mountain'
SELECT COUNT(T1.Issue) FROM events AS T1 INNER JOIN client AS T2 ON T1.Client_ID = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id WHERE T1.Issue = 'Billing disputes' AND T3.division = 'Mountain'
retail_complains
How many male clients are from the state of Massachusetts?
male refers to sex = 'Male';
Table state, columns = [`statecode` (statecode), `state` (state), `region` (region)] Table callcenterlogs, columns = [`date received` (date received), `complaint id` (complaint id), `rand client` (rand client), `phonefinal` (phone final), `vru+line` (voice response unit line), `call_id` (call id), `priority` (priority), `type` (type), `outcome` (outcome), `server` (server), `ser_start` (server start), `ser_exit` (server exit), `ser_time` (server time)] Table client, columns = [`client_id` (client id), `sex` (sex), `day` (day), `month` (month), `year` (year), `age` (age), `social` (social), `first` (first), `middle` (middle), `last` (last), `phone` (phone), `email` (email), `address_1` (address_1), `address_2` (address_2), `city` (city), `state` (state), `zipcode` (zipcode), `district_id` (district id)] Table district, columns = [`district_id` (district id), `city` (city), `state_abbrev` (state_abbrev), `division` (division)] Table events, columns = [`date received` (date received), `product` (product), `sub-product` (sub-product), `issue` (issue), `sub-issue` (sub-issue), `consumer complaint narrative` (consumer complaint narrative), `tags` (tags), `consumer consent provided?` (tags consumer consent provided?), `submitted via` (submitted via), `date sent to company` (date sent to company), `company response to consumer` (company response to consumer), `timely response?` (timely response?), `consumer disputed?` (consumer disputed?), `complaint id` (complaint id), `client_id` (client id)] Table reviews, columns = [`date` (date), `stars` (stars), `reviews` (reviews), `product` (product), `district_id` (district_id)] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
Table state, columns = [`statecode` (statecode. Example values: [AL, AR, AZ]), `state` (state. Example values: [Alabama, Arkansas, Arizona]), `region` (region. Example values: [South, West, Northeast])] Table callcenterlogs, columns = [`date received` (date received. Example values: [2017-03-27, 2017-03-23, 2017-03-22]), `complaint id` (complaint id. Example values: [None, CR0000072, CR0000084]), `rand client` (rand client. Example values: [C00004587, C00003328, C00001685]), `phonefinal` (phone final. Example values: [977-806-9726, 322-598-7152, 508-311-5237]), `vru+line` (voice response unit line. Example values: [AA0103, AA0205, AA0110]), `call_id` (call id. Example values: [34536, 34537, 34538]), `priority` (priority. Example values: [0, 2, 1]), `type` (type. Example values: [NW, PS, NE]), `outcome` (outcome. Example values: [AGENT, HANG, PHANTOM]), `server` (server. Example values: [MICHAL, TOVA, YIFAT]), `ser_start` (server start. Example values: [13:34:11, 10:58:22, 13:00:54]), `ser_exit` (server exit. Example values: [13:40:23, 11:16:10, 13:13:31]), `ser_time` (server time. Example values: [00:06:12, 00:17:48, 00:12:37])] Table client, columns = [`client_id` (client id. Example values: [C00000001, C00000002, C00000003]), `sex` (sex. Example values: [Female, Male]), `day` (day. Example values: [13, 4, 9]), `month` (month. Example values: [12, 2, 10]), `year` (year. Example values: [1990, 1965, 1960]), `age` (age. Example values: [29, 54, 59]), `social` (social. Example values: [926-93-2157, 806-94-5725, 614-70-9100]), `first` (first. Example values: [Emma, Noah, Olivia]), `middle` (middle. Example values: [Avaya, Everest, Brooklynne]), `last` (last. Example values: [Smith, Thompson, Johnson]), `phone` (phone. Example values: [367-171-6840, 212-423-7734, 212-425-6932]), `email` (email. Example values: [[email protected], [email protected], [email protected]]), `address_1` (address_1. Example values: [387 Wellington Ave., 75 W. Berkshire St., 36 Second St.]), `address_2` (address_2. Example values: [Unit 1, None, Unit 6]), `city` (city. Example values: [Albuquerque, New York City, Indianapolis]), `state` (state. Example values: [NM, NY, IN]), `zipcode` (zipcode. Example values: [47246, 10040, 10162]), `district_id` (district id. Example values: [18, 1, 5])] Table district, columns = [`district_id` (district id. Example values: [1, 2, 3]), `city` (city. Example values: [New York City, Jacksonville, Columbus]), `state_abbrev` (state_abbrev. Example values: [NY, FL, OH]), `division` (division. Example values: [Middle Atlantic, South Atlantic, East North Central])] Table events, columns = [`date received` (date received. Example values: [2014-07-03, 2012-04-12, 2012-04-03]), `product` (product. Example values: [Bank account or service, Credit card]), `sub-product` (sub-product. Example values: [Checking account, Savings account, None]), `issue` (issue. Example values: [Deposits and withdrawals, Account opening, closing, or management, Billing disputes]), `sub-issue` (sub-issue. Example values: [None]), `consumer complaint narrative` (consumer complaint narrative. Example values: [None]), `tags` (tags. Example values: [None, Older American, Older American, Servicemember]), `consumer consent provided?` (tags consumer consent provided?. Example values: [N/A, Consent not provided, None]), `submitted via` (submitted via. Example values: [Email, Fax, Postal mail]), `date sent to company` (date sent to company. Example values: [2014-07-09, 2012-04-13, 2012-04-03]), `company response to consumer` (company response to consumer. Example values: [Closed with explanation, Closed with relief, Closed without relief]), `timely response?` (timely response?. Example values: [Yes, No]), `consumer disputed?` (consumer disputed?. Example values: [No, None, Yes]), `complaint id` (complaint id. Example values: [CR0000072, CR0000084, CR0000140]), `client_id` (client id. Example values: [C00003714, C00001366, C00002330])] Table reviews, columns = [`date` (date. Example values: [2013-02-04, 2013-02-06, 2013-02-08]), `stars` (stars. Example values: [5, 1, 2]), `reviews` (reviews. Example values: []), `product` (product. Example values: [Eagle National Mortgage, Eagle National Bank, Eagle Capital]), `district_id` (district_id. Example values: [65, 66, 23])] foreign keys = [callcenterlogs.rand client = client.client_id, client.district_id = district.district_id, district.state_abbrev = state.StateCode, events.Client_ID = client.client_id, events.Complaint ID = callcenterlogs.Complaint ID, reviews.district_id = district.district_id]
SELECT COUNT(T3.sex) FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN client AS T3 ON T2.district_id = T3.district_id WHERE T1.state = 'Massachusetts' AND T3.sex = 'Male'
SELECT COUNT(T3.sex) FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN client AS T3 ON T2.district_id = T3.district_id WHERE T1.state = 'Massachusetts' AND T3.sex = 'Male'