Chinastark/bird_dataset huggingface dataset:
Database: book_publishing_company
Note: 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));
Question: In 1994 which title had less order quanty than the average order quantity? Find the title name, type and price.
SQL: SELECT DISTINCT titles.title, titles.type, titles.price FROM titles INNER JOIN sales ON titles.title_id = sales.title_id WHERE sales.ord_date LIKE '1994%' AND sales.qty < ( SELECT cast(sum(sales.qty) AS REAL) / count(titles.title_id) FROM titles INNER JOIN sales ON titles.title_id = sales.title_id )
Database: book_publishing_company
Note: Eric the Read Books is a publisher which refers to pub_name;
Question: List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.
SQL: SELECT titles.title, titles.type, titles.price FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE publishers.pub_name = 'New Moon Books' ORDER BY titles.price
Database: book_publishing_company
Note: US publisher refers publisher in the US where country = 'USA';
Question: In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.
SQL: SELECT titles.title FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id INNER JOIN roysched ON titles.title_id = roysched.title_id WHERE publishers.country = 'USA' ORDER BY titles.royalty DESC
Database: book_publishing_company
Note: 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'));
Question: Find the difference between the average royalty of titles published by US and non US publishers?
SQL: SELECT (cast(sum(CASE WHEN publishers.country = 'USA' THEN titles.royalty ELSE 0 END) AS REAL) / sum(CASE WHEN publishers.country = 'USA' THEN 1 ELSE 0 END)) - (cast(sum(CASE WHEN publishers.country != 'USA' THEN titles.royalty ELSE 0 END) AS REAL) / sum(CASE WHEN publishers.country != 'USA' THEN 1 ELSE 0 END)) FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id INNER JOIN roysched ON titles.title_id = roysched.title_id
Database: book_publishing_company
Note: 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);
Question: Calculate the average level difference between the Marketing editors hired by the US and non-US publishers?
SQL: SELECT (cast(sum(CASE WHEN publishers.country = 'USA' THEN job_lvl ELSE 0 END) AS REAL) / sum(CASE WHEN publishers.country = 'USA' THEN 1 ELSE 0 END)) - (cast(sum(CASE WHEN publishers.country != 'USA' THEN job_lvl ELSE 0 END) AS REAL) / sum(CASE WHEN publishers.country != 'USA' THEN 1 ELSE 0 END)) FROM publishers INNER JOIN employee ON publishers.pub_id = employee.pub_id INNER JOIN jobs ON employee.job_id = jobs.job_id WHERE jobs.job_desc = 'Managing Editor'
Database: book_publishing_company
Note: publisher refers to pub_name; about the title refers to notes;
Question: Which title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book?
SQL: SELECT titles.title, publishers.pub_name, titles.price FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.notes = 'Helpful hints on how to use your electronic resources to the best advantage.'
Database: book_publishing_company
Note: year to date sales refers to ytd_sales; about the title refers to notes;
Question: Of the titles, which title is about the Carefully researched study of the effects of strong emotions on the body, which state-based publisher published this book, and what is the year-to-date sale?
SQL: SELECT titles.title, publishers.pub_name, titles.ytd_sales FROM titles INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE titles.notes = 'Carefully researched study of the effects of strong emotions on the body. Metabolic charts included.'
Database: book_publishing_company
Note: qty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA";
Question: Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores?
SQL: SELECT titles.title FROM titles INNER JOIN sales ON titles.title_id = sales.title_id INNER JOIN publishers ON titles.pub_id = publishers.pub_id WHERE sales.qty > ( SELECT cast(sum(qty) AS REAL) / count(title_id) FROM sales ) AND publishers.state = 'CA' ORDER BY sales.qty DESC LIMIT 5
Database: retail_complains
Note: day received refers to "date received"; most verbose complaint refers to MAX(ser_time);
Question: On which day was the most verbose complaint received?
SQL: SELECT `date received` FROM callcenterlogs WHERE ser_time = ( SELECT max(ser_time) FROM callcenterlogs )
Database: retail_complains
Note: earliest complaint refers to oldest ser_start; on 2017/3/22 refers to "date received" = '2017-03-22';
Question: When did the earliest complaint start on 2017/3/22?
SQL: SELECT min(ser_time) FROM callcenterlogs WHERE `date received` = '2017-03-22'
Database: retail_complains
Note: more urgent refers to MAX(priority);
Question: Which complaint is more urgent, complaint ID CR2400594 or ID CR2405641?
SQL: SELECT CASE WHEN sum(CASE WHEN `complaint id` = 'CR2400594' THEN priority END) > sum(CASE WHEN `complaint id` = 'CR2405641' THEN priority END) THEN 'CR2400594' ELSE 'CR2405641' END FROM callcenterlogs
Database: retail_complains
Note: full names = first, middle, last; male refers to sex = 'Male'; year > 1990;
Question: Please list the full names of all the male clients born after the year 1990.
SQL: SELECT FIRST, middle, LAST FROM client WHERE YEAR > 1990
Database: retail_complains
Question: How many complaints have the client Diesel Galloway filed?
SQL: SELECT count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Diesel' AND client.last = 'Galloway'
Database: retail_complains
Note: detailed product refers to "sub-product"; on 2014/7/3 refers to "date received" = '2014-07-03';
Question: What is the detailed product of the complaint filed by Diesel Galloway on 2014/7/3?
SQL: SELECT EVENTS.`sub-product` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Diesel' AND client.last = 'Galloway' AND EVENTS.`date received` = '2014-07-03'
Database: retail_complains
Note: 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;
Question: Was the tag in the complaint filed by Matthew Pierce on 2016/10/28 approved by himself?
SQL: SELECT CASE WHEN EVENTS.`consumer consent provided?` IN (NULL, 'N/A', 'Empty') THEN 'No' ELSE 'Yes' END FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Matthew' AND client.last = 'Pierce' AND EVENTS.`date received` = '2016-10-28'
Database: retail_complains
Note: on 2016/10/28 refers to "date received" = '2016-10-28'; delayed = SUBTRACT("date sent to company', 'date received");
Question: For how long was the complaint filed by Matthew Pierce on 2016/10/28 delayed?
SQL: SELECT 365 * (strftime('%Y', EVENTS.`date sent to company`) - strftime('%Y', EVENTS.`date received`)) + 30 * (strftime('%M', EVENTS.`date sent to company`) - strftime('%M', EVENTS.`date received`)) + (strftime('%d', EVENTS.`date sent to company`) - strftime('%d', EVENTS.`date received`)) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Matthew' AND client.last = 'Pierce' AND EVENTS.`date received` = '2016-10-28'
Database: retail_complains
Note: full names = first, middle, last; on 2017/3/27 refers to "date received" = '2017-03-27'; MICHAL refers to server = 'MICHAL';
Question: What is the full name of the client whose complaint on 2017/3/27 was received by MICHAL?
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.`date received` = '2017-03-27' AND callcenterlogs.server = 'MICHAL'
Database: retail_complains
Note: how long did the complaint filed last refers to ser_time; on 2017/3/27 refers to "date received" = '2017-03-27';
Question: For how long did the complaint filed on 2017/3/27 by Rachel Hicks last?
SQL: SELECT callcenterlogs.ser_time FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.first = 'Rachel' AND client.last = 'Hicks' AND callcenterlogs.`date received` = '2017-03-27'
Database: retail_complains
Question: Among all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?
SQL: SELECT count(EVENTS.issue) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.issue = 'Deposits and withdrawals' AND client.city = 'New York City'
Database: retail_complains
Note: full name = first, middle, last; complaints are still in progress refers to "company response to consumer" = 'In progress';
Question: Please list the full names of all the clients whose complaints are still in progress.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`company response to consumer` = 'In progress'
Database: retail_complains
Note: did not receive a timely response refers to "timely response?" = 'No'; New York refers to city = 'New York';
Question: Among the clients who did receive a timely response for their complaint, how many of them are from New York?
SQL: SELECT count(client.city) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`timely response?` = 'No' AND client.city = 'New York City'
Database: retail_complains
Note: credit cards refers to product = 'Credit card'; 2016 refers to year(date received) = 2016; male refers to sex = 'Male';
Question: How many complaints on credit cards in the year 2016 were filed by male clients?
SQL: SELECT count(client.sex) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE strftime('%Y', EVENTS.`date received`) = '2016' AND client.sex = 'Male' AND EVENTS.product = 'Credit card'
Database: retail_complains
Question: Which division is Diesel Galloway in?
SQL: SELECT district.division FROM client INNER JOIN district ON client.district_id = district.district_id WHERE client.first = 'Diesel' AND client.last = 'Galloway'
Database: retail_complains
Note: full names = first, middle, last; male refers to sex = 'Male';
Question: Please list the full names of all the male clients in the Pacific division.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.division = 'Pacific' AND client.sex = 'Male'
Database: retail_complains
Note: 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;
Question: What is the average number of complaints on credit cards filed by clients from New York in the 3 consecutive years starting from 2015?
SQL: SELECT cast(count(EVENTS.`complaint id`) AS REAL) / 3 AS average FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE strftime('%Y', EVENTS.`date received`) BETWEEN '2015' AND '2017' AND client.city = 'New York City' AND EVENTS.product = 'Credit card'
Database: retail_complains
Note: 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;
Question: What is the percentage of the increase of complaints filed by the clients from New York from the year 2016 to the year 2017?
SQL: SELECT 100.0 * (sum(CASE WHEN strftime('%Y', EVENTS.`date received`) = '2017' THEN 1 ELSE 0 END) - sum(CASE WHEN strftime('%Y', EVENTS.`date received`) = '2016' THEN 1 ELSE 0 END)) / sum(CASE WHEN strftime('%Y', EVENTS.`date received`) = '2016' THEN 1 ELSE 0 END) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.city = 'New York City'
Database: retail_complains
Note: 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';
Question: What was the serve time for the complaint call from client "C00007127" on 2017/2/22?
SQL: SELECT callcenterlogs.ser_time FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE EVENTS.client_id = 'C00007127' AND callcenterlogs.`date received` = '2017-02-22'
Database: retail_complains
Note: full name of the state refers to state_name;
Question: Which state does the owner of "wyatt.collins@gmail.com" live in? Give the full name of the state.
SQL: SELECT client.state FROM client INNER JOIN district ON client.district_id = district.district_id WHERE client.email = 'wyatt.collins@gmail.com'
Database: retail_complains
Note: detailed product refers to "sub-product"; Mr refers to sex = 'Male';
Question: Which detailed product did Mr Lennox Oliver Drake complain about?
SQL: SELECT DISTINCT EVENTS.`sub-product` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Lennox' AND client.middle = 'Oliver' AND client.last = 'Drake' AND client.sex = 'Male'
Database: retail_complains
Note: detailed issue refers to sub-issue; Mr refers to sex = 'Male';
Question: What was the detailed issue did Mr Gunner Omer Fuller complain about?
SQL: SELECT EVENTS.`sub-issue` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Gunner' AND client.middle = 'Omer' AND client.last = 'Fuller' AND client.sex = 'Male'
Database: retail_complains
Note: 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';
Question: Did Ms. Lyric Emely Taylor provide the consent for result of the complaint call on 2016/5/20?
SQL: SELECT CASE WHEN EVENTS.`consumer consent provided?` IN (NULL, 'N/A', '') THEN 'No' ELSE 'Yes' END FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Lyric' AND client.middle = 'Emely' AND client.last = 'Taylor' AND client.sex = 'Female' AND EVENTS.`date received` = '2016-05-20'
Database: retail_complains
Note: 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';
Question: How many days delay for the complaint call from Mr. Brantley Julian Stanley on 2012/5/18?
SQL: SELECT 365 * (strftime('%Y', EVENTS.`date sent to company`) - strftime('%Y', EVENTS.`date received`)) + 30 * (strftime('%M', EVENTS.`date sent to company`) - strftime('%M', EVENTS.`date received`)) + (strftime('%d', EVENTS.`date sent to company`) - strftime('%d', EVENTS.`date received`)) AS days FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`date received` = '2012-05-18' AND client.sex = 'Male' AND client.first = 'Brantley' AND client.middle = 'Julian' AND client.last = 'Stanley'
Database: retail_complains
Note: on 2018/9/11 refers to date = '2017-07-22';
Question: Which district did the review on 2018/9/11 come from? Give the name of the city.
SQL: SELECT district.district_id, district.city FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE reviews.date = '2018-09-11'
Database: retail_complains
Note: Jacksonville refers to city = 'Jacksonville'; on 2017/7/22 refers to date = '2017-07-22';
Question: What was the review context from Jacksonville on 2017/7/22?
SQL: SELECT reviews.reviews FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE district.city = 'Jacksonville' AND reviews.date = '2017-07-22'
Database: retail_complains
Note: Indianapolis refers to state = 'Indianapolis'; on 2016/10/7 refers to date = '2013-04-04';
Question: Which product received a review from Indianapolis on 2016/10/7?
SQL: SELECT reviews.product FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE district.city = 'Indianapolis' AND reviews.date = '2016-10-07'
Database: retail_complains
Note: Eagle Capital refers to product = 'Eagle Capital'; Little Rock is a city; on 2013/4/4 refers to date = '2013-04-04';
Question: How many stars did "Eagle Capital" received from Little Rock on 2013/4/4?
SQL: SELECT count(reviews.stars) FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE reviews.product = 'Eagle Capital' AND district.city = 'Little Rock' AND reviews.date = '2013-04-04'
Database: retail_complains
Note: complaint call refers to complaint id; birthday = year, month, day;
Question: For the client who made the complaint call "CR0217298", what was his/her birthday？
SQL: SELECT client.month, client.day FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`complaint id` = 'CR0217298'
Database: retail_complains
Note: complaint call refers to complaint id;
Question: What was the phone of number of the client who made the complaint call "CR0100432" ？
SQL: SELECT client.phone FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`complaint id` = 'CR0100432'
Database: retail_complains
Note: 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';
Question: For all the complaint callers on 2017/3/27, what percentage of the clients are females?
SQL: SELECT cast(sum(CASE WHEN client.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / count(client.sex) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`date received` = '2017-03-27'
Database: retail_complains
Note: 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';
Question: What is the percentage of the complaint calls from Mr Mason Javen Lopez has got the consent provided by the customer?
SQL: SELECT cast(sum(CASE WHEN EVENTS.`consumer consent provided?` = 'Consent provided' THEN 1 ELSE 0 END) AS REAL) * 100 / count(EVENTS.`consumer consent provided?`) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.sex = 'Male' AND client.first = 'Mason' AND client.middle = 'Javen' AND client.last = 'Lopez'
Database: retail_complains
Note: urgent complaints refers to priority = 2; march of 2017 refers to "date received" BETWEEN '2017-01-01' AND '2017-01-31';
Question: How many priority urgent complaints were received in march of 2017? List the complaint ID of these complaints.
SQL: SELECT count(`complaint id`) FROM callcenterlogs WHERE `date received` LIKE '2017-01%' AND priority = ( SELECT max(priority) FROM callcenterlogs )
Database: retail_complains
Note: full name = first, middle, last; date of birth = year, month, day; elderly clients refers to age > 65;
Question: Please list the full name, date of birth, and email id of the elderly clients in descending order of age.
SQL: SELECT FIRST, middle, LAST, YEAR, MONTH , DAY, email FROM client WHERE age > 65 ORDER BY age DESC
Database: retail_complains
Note: most five stars refers to MAX(COUNT(stars = 5));
Question: Which product got the most five stars, and how many?
SQL: SELECT t.product, max(t.num) FROM ( SELECT product, count(stars) AS num FROM reviews WHERE stars = 5 GROUP BY product ) t
Database: retail_complains
Question: List all the states in the South region.
SQL: SELECT state FROM state WHERE region = 'South'
Database: retail_complains
Note: email id refers to email; calls were hung refers to outcome = 'Hang';
Question: What is the email id of clients whose calls were hung?
SQL: SELECT client.email FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.outcome = 'HANG'
Database: retail_complains
Note: average age = AVG(age);
Question: Calculate the average age of clients from the Midwest region.
SQL: SELECT cast(sum(client.age) AS REAL) / count(state.region) AS average FROM client INNER JOIN district ON client.district_id = district.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE state.region = 'Midwest'
Database: retail_complains
Note: full name = first, middle, last; submitted the complaint via fax refers to "submitted via" = 'fax';
Question: List the full name and phone number of clients who submitted the complaint via fax.
SQL: SELECT client.first, client.middle, client.last, client.phone FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`submitted via` = 'Fax'
Database: retail_complains
Note: below average = AVG(stars) < stars; Eagle Capital refers to product = 'Eagle Capital';
Question: Find and list the names of districts which has below-average stars for Eagle Capital.
SQL: SELECT district.division FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE reviews.product = 'Eagle Capital' AND reviews.stars > ( SELECT avg(stars) FROM reviews INNER JOIN district ON reviews.district_id = district.district_id )
Database: retail_complains
Note: teenage refers to age BETWEEN 12 AND 20;
Question: In the calls from the mountain division, how many are from teenage clients?
SQL: SELECT count(client.age) FROM client INNER JOIN district ON client.district_id = district.district_id WHERE client.age BETWEEN 12 AND 20 AND district.division = 'Mountain'
Database: retail_complains
Note: Credit cards refers to product = 'Credit card'; female refers to sex = 'female';
Question: What is the number of complaints related to Credit cards came from female clients?
SQL: SELECT count(client.sex) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.sex = 'Female' AND EVENTS.product = 'Credit card'
Database: retail_complains
Note: 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";
Question: Among the clients born between 1980 and 2000, list the name of male clients who complained through referral.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.year BETWEEN 1980 AND 2000 AND client.sex = 'Male' AND EVENTS.`submitted via` = 'Referral'
Database: retail_complains
Note: medium refers to "submitted via"; most complaints refers to MAX(complaint id); Florida refers to state = 'florida';
Question: What is the medium through which most complaints are registered in Florida?
SQL: SELECT EVENTS.`submitted via` FROM callcenterlogs INNER JOIN client ON callcenterlogs.`rand client` = client.client_id INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE client.state = 'FL' GROUP BY callcenterlogs.`complaint id` ORDER BY count(callcenterlogs.`complaint id`) DESC LIMIT 1