Chinastark/bird_dataset huggingface dataset:
Database: retail_complains
Note: average = AVG("complaint id"); New Bedford refers to city = 'New Bedford'; closed with explanation refers to company response to consumer = 'Closed with explanation';
Question: Calculate the average number of complaints received from New Bedford each year which are closed with explanation.
SQL: SELECT strftime('%Y', EVENTS.`date received`) , cast(sum(CASE WHEN EVENTS.`company response to consumer` = 'Closed with explanation' THEN 1 ELSE 0 END) AS REAL) / count(EVENTS.`complaint id`) AS average FROM callcenterlogs INNER JOIN client ON callcenterlogs.`rand client` = client.client_id INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE client.city = 'New Bedford' GROUP BY strftime('%Y', EVENTS.`date received`)
Database: retail_complains
Note: percentage = MULTIPLY(DIVIDE(SUM("consumer disputed?" = 'Yes' AND city = 'Houston'), COUNT(client_id)), 1.0); Houston refers to city = 'Houston';
Question: What percentage of consumers from Houston disputed complaints?
SQL: SELECT cast(sum(CASE WHEN EVENTS.`consumer disputed?` = 'Yes' AND client.city = 'Houston' THEN 1 ELSE 0 END) AS REAL) * 100 / count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id
Database: retail_complains
Note: service members refers to client.client_id; Syracuse refers to city = 'Syracuse';
Question: Find the number of service members who complained in Syracuse.
SQL: SELECT count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.tags = 'Servicemember' AND client.city = 'Syracuse'
Database: retail_complains
Note: California refers to state = 'California'; percentage = MULTIPLY(DIVIDE(SUM(priority = 1), COUNT("complaint id"), 1.0));
Question: Among the calls from California, what percentage are priority 1?
SQL: SELECT cast(sum(CASE WHEN callcenterlogs.priority = 1 THEN 1 ELSE 0 END) AS REAL) * 100 / count(callcenterlogs.priority) FROM callcenterlogs INNER JOIN client ON callcenterlogs.`rand client` = client.client_id INNER JOIN district ON client.district_id = district.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE state.state = 'California'
Database: retail_complains
Note: 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;
Question: Calculate the difference in the average age of elderly and middle-aged clients in the Northeast region.
SQL: SELECT (cast(sum(CASE WHEN client.age BETWEEN 35 AND 55 THEN client.age ELSE 0 END) AS REAL) / sum(CASE WHEN client.age BETWEEN 35 AND 55 THEN 1 ELSE 0 END)) - (cast(sum(CASE WHEN client.age > 65 THEN client.age ELSE 0 END) AS REAL) / sum(CASE WHEN client.age > 65 THEN 1 ELSE 0 END)) AS difference FROM client INNER JOIN district ON client.district_id = district.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE state.region = 'Northeast'
Database: retail_complains
Note: ID number refers to "complaint id"; longest complaints refers to MAX(ser_time);
Question: List by their ID number the 3 longest complaints.
SQL: SELECT `complaint id` FROM callcenterlogs ORDER BY ser_time DESC LIMIT 3
Database: retail_complains
Note: email account other than gmail.com refers to email not like '%@gmail.com';
Question: How many clients have an email account other than gmail.com?
SQL: SELECT count(email) FROM client WHERE email NOT LIKE '%@gmail.com'
Database: retail_complains
Note: did not give their consent permission refers to Consumer consent provided is null, 'N/A', or empty;
Question: Identify by their ID all clients who did not give their consent permission.
SQL: SELECT client_id FROM EVENTS WHERE `consumer consent provided?` = 'N/A' OR 'Consumer consent provided?' IS NULL OR 'Consumer consent provided?' = ''
Database: retail_complains
Note: 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"));
Question: List by their ID the complaints received by the company on 25/09/2014 that took the longest.
SQL: 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'
Database: retail_complains
Question: List priority 2 complaints by date received.
SQL: SELECT DISTINCT `complaint id` FROM callcenterlogs WHERE priority = 2 ORDER BY `date received` DESC
Database: retail_complains
Note: not in process with an agent refers to outcome ! = 'ageNT';
Question: How many complaints are not in process with an agent?
SQL: SELECT count(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'
Database: retail_complains
Note: Credit Card refers to product = 'Credit Card'; Sharon refers to server = 'SHARON';
Question: How many Credit Card complaints did Sharon handle?
SQL: SELECT count(callcenterlogs.`complaint id`) FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE EVENTS.product = 'Credit card' AND callcenterlogs.server = 'SHARON'
Database: retail_complains
Note: most 1-star reviews refers to MAX(COUNT(stars = 1));
Question: In which region have the most 1-star reviews been done?
SQL: SELECT state.region FROM reviews INNER JOIN district ON reviews.district_id = district.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE reviews.stars = 1 GROUP BY state.region ORDER BY count(state.region) DESC LIMIT 1
Database: retail_complains
Note: more problems with Certificate refers to MAX(COUNT("sub-product" = '(CD) Certificate of deposit'));
Question: In what years were the clients who demanded more problems with Certificate of deposit born?
SQL: SELECT client.year FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`sub-product` = '(CD) Certificate of deposit' GROUP BY client.year ORDER BY count(client.year) DESC LIMIT 1
Database: retail_complains
Note: billing dispute refers to issue = 'Billing disputes';
Question: How many cases of billing dispute issues occurred in the Mountain division?
SQL: SELECT count(EVENTS.issue) FROM EVENTS INNER JOIN client ON EVENTS.client_id = client.client_id INNER JOIN district ON client.district_id = district.district_id WHERE EVENTS.issue = 'Billing disputes' AND district.division = 'Mountain'
Database: retail_complains
Note: male refers to sex = 'Male';
Question: How many male clients are from the state of Massachusetts?
SQL: SELECT count(client.sex) FROM state INNER JOIN district ON state.statecode = district.state_abbrev INNER JOIN client ON district.district_id = client.district_id WHERE state.state = 'Massachusetts' AND client.sex = 'Male'
Database: retail_complains
Note: PS-type complaint refers to type = 'PS'; served by refers to server;
Question: Lists the last name of all clients who made a PS-type complaint and were served by TOVA.
SQL: SELECT client.last FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.type = 'PS' AND callcenterlogs.server = 'TOVA'
Database: retail_complains
Note: age < 35; Eagle National Mortgage refers to product = 'Eagle National Mortgage';
Question: How many clients under the age of 35 gave Eagle National Mortgage 1 star?
SQL: SELECT count(client.age) FROM reviews INNER JOIN client ON reviews.district_id = client.district_id WHERE reviews.product = 'Eagle National Mortgage' AND reviews.stars = 1 AND client.age < 35
Database: retail_complains
Note: male refers to sex = 'Male';
Question: How many male clients born in the year 1977 were given priority 0 in their complaints?
SQL: SELECT count(client.sex) FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.sex = 'Male' AND callcenterlogs.priority = 0 AND client.year = 1997
Database: retail_complains
Note: name refers to first; provided consent refers to "consumer consent provided?" not in ('N/A', null, 'empty');
Question: List by name all customers who provided consent for the tag Older American.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.tags = 'Older American' AND EVENTS.`consumer consent provided?` != 'N/A' AND EVENTS.`consumer consent provided?` IS NOT NULL AND EVENTS.`consumer consent provided?` != ''
Database: retail_complains
Note: largest number of complaints refers to MAX(COUNT("complaint id") WHERE priority = 0);
Question: What is the name of the state in which there have been the largest number of complaints with priority 0?
SQL: SELECT client.state FROM callcenterlogs INNER JOIN client ON callcenterlogs.`rand client` = client.client_id INNER JOIN district ON client.district_id = district.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE callcenterlogs.priority = 0 GROUP BY client.state ORDER BY count(client.state) DESC LIMIT 1
Database: retail_complains
Note: women refers to sex = 'Female'; served after 3 pm refers to ser_time BETWEEN '15:00:01' AND '23:59:59'; received a timely response refers to "timely response?" = 'Yes';
Question: How many complaints made by women and served after 3 pm received a timely response from the company?
SQL: SELECT count(callcenterlogs.`complaint id`) FROM callcenterlogs INNER JOIN client ON callcenterlogs.`rand client` = client.client_id INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE client.sex = 'Female' AND callcenterlogs.ser_start BETWEEN '15:00:01' AND '23:59:59' AND EVENTS.`timely response?` = 'Yes'
Database: retail_complains
Note: served in 5 minutes or less refers to ser_time < '00:05:00'; DORIT refers to server = 'DORIT'; responded with an explanation refers to "company response to consumer" = 'Closed with explanation'; made by refers to "submitted via";
Question: How many complaints were served in 5 minutes or less by DORIT and responded to the customer with an explanation, were made by phone?
SQL: SELECT count(callcenterlogs.`complaint id`) FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE callcenterlogs.ser_time < '00:05:00' AND callcenterlogs.server = 'DORIT' AND EVENTS.`submitted via` = 'Phone' AND EVENTS.`company response to consumer` = 'Closed with explanation'
Database: retail_complains
Note: The abbreviation of Maryland is 'MD';
Question: How many clients with the last name Alvarado are from Maryland?
SQL: SELECT count(client.client_id) FROM district INNER JOIN client ON district.district_id = client.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE client.last = 'Alvarado' AND client.state = 'MD'
Database: retail_complains
Note: between 30 and 50 years refers to age BETWEEN 30 AND 50; include the word great refers to Review like '%Great%';
Question: How many reviews by people between 30 and 50 years include the word 'great'?
SQL: SELECT count(reviews.reviews) FROM reviews INNER JOIN client ON reviews.district_id = client.district_id WHERE client.age BETWEEN 30 AND 50 AND reviews.reviews LIKE '%great%'
Database: retail_complains
Note: full address = address_1, address_2; received a timely response refers to timely response? = 'Yes'; have dispute refers to "consumer disputed?" = 'Yes';
Question: What is the full address of the customers who, having received a timely response from the company, have dispute about that response?
SQL: SELECT client.address_1, client.address_2 FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`timely response?` = 'Yes' AND EVENTS.`consumer disputed?` = 'Yes'
Database: retail_complains
Note: female refers to sex = 'Female'; sent through refers to "submitted via"; not sent through web refers to "submitted via" ! = 'Web';
Question: How many complaints from female clients born in the year 2000 were not sent through the web?
SQL: SELECT count(EVENTS.`submitted via`) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.sex = 'Female' AND client.year = 2000 AND EVENTS.`submitted via` != 'Web'
Database: retail_complains
Note: complaints narratives refers to "consumer complaint narrative";
Question: List all the complaints narratives made by the customer named Brenda and last name Mayer.
SQL: SELECT EVENTS.`consumer complaint narrative` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Brenda' AND client.last = 'Mayer'
Database: retail_complains
Note: gmail.com email refers to email like '%gmail.com'; in February 2017 refers to "date received" BETWEEN '2017-01-02' AND '2017-02-28';
Question: How many complaints from customers with a gmail.com email were received by the company in February 2017?
SQL: SELECT count(client.email) FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE (callcenterlogs.`date received` LIKE '2017-02%' OR callcenterlogs.`date received` LIKE '2017-01%') AND client.email LIKE '%@gmail.com'
Database: retail_complains
Note: average = DIVIDE(SUM(state = 'Oregon'), COUNT(district_id)); Oregon refers to state = 'Oregon';
Question: What is the average number of stars given by Oregon clients in their reviews?
SQL: SELECT cast(sum(reviews.stars) AS REAL) / count(reviews.stars) AS average FROM state INNER JOIN district ON state.statecode = district.state_abbrev INNER JOIN reviews ON district.district_id = reviews.district_id WHERE state.state = 'Oregon'
Database: retail_complains
Note: percentage = MULTIPLY(DIVIDE(SUM("submitted via" = 'Postal mail'), COUNT(client_id)), 1.0); sent their complaints by refers to "submitted via"; age > 50;
Question: What percentage of clients who sent their complaints by postal mail are age 50 and older?
SQL: SELECT cast(sum(CASE WHEN client.age > 50 THEN 1 ELSE 0 END) AS REAL) * 100 / count(EVENTS.`submitted via`) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`submitted via` = 'Postal mail'
Database: retail_complains
Note: average age = AVG(age); Norwalk refers to city = 'Norwalk';
Question: What is the average age of Norwalk clients?
SQL: SELECT cast(sum(client.age) AS REAL) / count(client.age) AS average FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.city = 'Norwalk'
Database: retail_complains
Note: 1-star review refers stars = 1;
Question: How many clients who live in Kansas City provided a 1-star review?
SQL: SELECT count(reviews.stars) FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE district.city = 'Kansas City' AND reviews.stars = 1
Database: retail_complains
Note: highest number of clients refers to MAX(COUNT(client_id)); 5-star review refers to stars = 5;
Question: Which state has the highest number of clients who gave a 5-star review?
SQL: SELECT district.state_abbrev FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE reviews.stars = 5 GROUP BY district.state_abbrev ORDER BY count(district.state_abbrev) DESC LIMIT 1
Database: retail_complains
Question: Which region does Noah Thompson live in?
SQL: SELECT district.division FROM client INNER JOIN district ON client.district_id = district.district_id WHERE client.first = 'Noah' AND client.last = 'Thompson'
Database: retail_complains
Note: how it was submitted refers to "submitted via";
Question: How did Kyran Muller submit his complaint?
SQL: SELECT DISTINCT EVENTS.`submitted via` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Kyran' AND client.last = 'Muller'
Database: retail_complains
Note: year > 2005;
Question: What are the products that people who were born after 2005 complain about?
SQL: SELECT DISTINCT EVENTS.product FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.year > 2005
Database: retail_complains
Note: how long refers to ser_time; credit card refers to product = 'Credit Card';
Question: How long was Kendall Allen's complaint about her credit card?
SQL: SELECT callcenterlogs.ser_time FROM EVENTS INNER JOIN client ON EVENTS.client_id = client.client_id INNER JOIN callcenterlogs ON EVENTS.`complaint id` = callcenterlogs.`complaint id` WHERE client.first = 'Kendall' AND client.last = 'Allen' AND client.sex = 'Female' AND EVENTS.product = 'Credit card'
Database: retail_complains
Note: longest server time refers to MAX(ser_time);
Question: What was the issue that the client with the longest server time faced?
SQL: SELECT EVENTS.issue FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE callcenterlogs.ser_time = ( SELECT max(ser_time) FROM callcenterlogs )
Database: retail_complains
Note: submitted complaints via fax refers to "submitted via" = 'Fax';
Question: How many clients who live in New York City submitted their complaints via fax?
SQL: SELECT count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.city = 'New York City' AND EVENTS.`submitted via` = 'Fax'
Database: retail_complains
Note: percentage = MULTIPLY(DIVIDE(SUM(sex = 'Male'), COUNT(client_id)), 1.0); male refers to sex = 'Male'; credit cards refers to product = 'Credit card';
Question: What is the percentage of male clients complaining about their credit cards?
SQL: SELECT cast(sum(CASE WHEN client.sex = 'Male' 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.product = 'Credit card'
Database: retail_complains
Note: full names = first, middle, last; without seeking their permission refers to "consumer consent provided?" in (null, 'N/A' or 'empty');
Question: Please list any two clients with their full names who have been tagged as "Older American" by the company without seeking their permission.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.tags = 'Older American' AND EVENTS.`consumer consent provided?` IN (NULL, 'N/A', '') LIMIT 2
Database: retail_complains
Note: birth date refers to year, month, day; youngest client refers to max(year, month, day);
Question: What is the birth date of the youngest client?
SQL: SELECT DAY, MONTH, YEAR FROM client ORDER BY YEAR DESC, MONTH DESC, DAY DESC LIMIT 1
Database: retail_complains
Note: no dispute refers to consumer disputed? = 'No'; non-timely response refers to timely response? = 'No';
Question: How many times does the consumer have no dispute over a non-timely response from the company?
SQL: SELECT count(`timely response?`) FROM EVENTS WHERE `timely response?` = 'No' AND `consumer disputed?` = 'No'
Database: retail_complains
Note: longer than 15 minutes refers to ser_time > '00:15:00';
Question: How many of the complaints are longer than 15 minutes?
SQL: SELECT count(ser_time) FROM callcenterlogs WHERE strftime('%M', ser_time) > '15'
Database: retail_complains
Note: most common refers to max(count(issue)); highest priority refers to priority = 2;
Question: What is the most common issue for the highest priority complaints?
SQL: SELECT EVENTS.issue FROM EVENTS INNER JOIN callcenterlogs ON EVENTS.`complaint id` = callcenterlogs.`complaint id` WHERE callcenterlogs.priority = 2 GROUP BY EVENTS.issue ORDER BY count(EVENTS.issue) DESC LIMIT 1
Database: retail_complains
Note: full name refers to first, last;
Question: List the full names of all clients who live in the Pacific division.
SQL: SELECT client.first, client.middle, client.last FROM district INNER JOIN client ON district.district_id = client.district_id WHERE district.division = 'Pacific'
Database: retail_complains
Note: social number refers to social; most complaints refers to max(count(event.client_id));
Question: What is the social number of the person who made the most complaints?
SQL: SELECT client.social FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id GROUP BY client.client_id ORDER BY count(client.client_id) DESC LIMIT 1
Database: retail_complains
Note: most refers to max(count(state_abbrev)); 1 star review refers to stars = 1;
Question: Which is the city where most of the 1 star reviews come from?
SQL: SELECT district.city FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE reviews.stars = 1 GROUP BY district.city ORDER BY count(district.city) DESC LIMIT 1
Database: retail_complains
Note: address refers to address_1, address_2; via postal mail refers to submitted via = 'Postal mail'; March 14 2012 refers to date received = '2012-03-14';
Question: What is the address of the client who made a complaint via postal mail on March 14, 2012?
SQL: SELECT client.address_1, client.address_2 FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`date received` = '2012-03-14' AND EVENTS.`submitted via` = 'Postal mail'
Database: retail_complains
Note: female refers to sex = 'Female';
Question: Among the female clients, how many of them have a complaint with a priority of 1?
SQL: SELECT count(client.client_id) FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.sex = 'Female' AND callcenterlogs.priority = 1
Database: retail_complains
Note: phone complaint refers to submitted via = 'phone'; late response refers to timely response? = 'No';
Question: List all the server of the phone complaints with a late response from the company.
SQL: SELECT DISTINCT callcenterlogs.server FROM EVENTS INNER JOIN callcenterlogs ON EVENTS.`complaint id` = callcenterlogs.`complaint id` WHERE EVENTS.`submitted via` = 'Phone' AND EVENTS.`timely response?` = 'No'
Database: retail_complains
Question: List all the issues of the complaints made by Kaitlyn Eliza Elliott.
SQL: SELECT DISTINCT EVENTS.issue FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Kaitlyn' AND client.middle = 'Eliza' AND client.last = 'Elliott'
Database: retail_complains
Question: What is the name of the state that the client with the email "skylar.ramirez@gmail.com" lives in?
SQL: SELECT client.state FROM state INNER JOIN district ON state.statecode = district.state_abbrev INNER JOIN client ON district.district_id = client.district_id WHERE client.email = 'skylar.ramirez@gmail.com'
Database: retail_complains
Note: region refers to division; second most refers to second max(client_id);
Question: Which region has the second most clients?
SQL: SELECT district.division FROM client INNER JOIN district ON client.district_id = district.district_id GROUP BY district.division ORDER BY count(district.division) DESC LIMIT 1, 1
Database: retail_complains
Note: owner refers to first, middle, last; on 9/11/2013 refers to date received = '2013-09-11';
Question: Who is the owner of the final phone number for the complaints on server "MORIAH" on 9/11/2013?
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.server = 'MORIAH' AND callcenterlogs.`date received` = '2013-09-11'