Chinastark/bird_dataset huggingface dataset:
Database: retail_complains
Note: teenager refers to 13 < age <= 19; adult refers to 19 < age <= 65; elder refers to age <= 65; highest average time per complaint = max(divide(sum(ser_time), count(ser_time)));
Question: Compute the average time in minute for each age group
SQL: SELECT cast(sum(CASE WHEN client.age > 13 AND client.age <= 19 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / sum(CASE WHEN client.age > 13 AND client.age <= 19 THEN 1 ELSE 0 END) AS teenageraveragemins, cast(sum(CASE WHEN client.age > 19 AND client.age <= 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / sum(CASE WHEN client.age > 19 AND client.age <= 65 THEN 1 ELSE 0 END) AS adultaveragemins , cast(sum(CASE WHEN client.age > 65 THEN 60 * strftime('%H', ser_time) + strftime('%M', ser_time) + strftime('%S', ser_time) / 60 ELSE 0 END) AS REAL) / sum(CASE WHEN client.age > 65 THEN 1 ELSE 0 END) AS elderaveragemins FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client`
Database: retail_complains
Note: elder refers to age <= 65; percentage refers to divide(sum(age <= 65) , count(client_id)) * 100%;
Question: What percentage of complaints are from the elderly?
SQL: SELECT cast(sum(CASE WHEN client.age > 65 THEN 1 ELSE 0 END) AS REAL) * 100 / count(client.age) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id
Database: retail_complains
Note: male refers to sex = 'Male'; Indianapolis city refers to city = 'Indianapolis'; percentage = divide(count(client_id where sex = 'Male' and city = 'Indianapolis') , count(client_id where city = 'Indianapolis')) * 100%;
Question: Calculate the percentage of male clients from Indianapolis City.
SQL: SELECT cast(sum(CASE WHEN sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / count(client_id) FROM client WHERE city = 'Indianapolis'
Database: retail_complains
Note: teenager refers to 13 < age <= 19; Google account refers to email like '%@gmail.com'; Microsoft account refers to email like '%@outlook.com';
Question: Among the teenager clients who use Google account and Microsoft account, which group of client is more than the other?
SQL: SELECT CASE WHEN sum(CASE WHEN email LIKE '%@gmail.com' THEN 1 ELSE 0 END) > sum(CASE WHEN email LIKE '%@outlook.com' THEN 1 ELSE 0 END) THEN 'Google account' ELSE 'Microsoft account' END FROM client WHERE age BETWEEN 13 AND 19
Database: retail_complains
Note: full name refers to first middle last;
Question: What is the full name of client whose email address is emily.garcia43@outlook.com?
SQL: SELECT FIRST, middle, LAST FROM client WHERE email = 'emily.garcia43@outlook.com'
Database: retail_complains
Note: first name refers to first; highest priority refers to priority = 2;
Question: What is the first name of clients who have the highest priority?
SQL: SELECT client.first FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.priority = ( SELECT max(priority) FROM callcenterlogs )
Database: retail_complains
Question: List down the email of client whose complaint is type "PS".
SQL: SELECT client.email FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.type = 'PS'
Database: retail_complains
Note: elder refers to age <= 65; last name refers to last;
Question: Among the elderlies, state the last name of whose complaint is handled in server YIFAT?
SQL: SELECT client.last FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.age > 65 AND callcenterlogs.server = 'YIFAT'
Database: retail_complains
Note: New York city refers to city = 'New York city';
Question: How many clients who live in New York City have the complaint outcome as "AGENT"?
SQL: SELECT count(callcenterlogs.`rand client`) FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.city = 'New York City' AND callcenterlogs.outcome = 'AGENT'
Database: retail_complains
Note: full name refers to first, middle, last; disputed the response refers to consumer disputed? = 'Yes';
Question: List down the full name of clients who have disputed the response from company.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`consumer disputed?` = 'Yes'
Database: retail_complains
Note: in 1931 refers to year = 1931;
Question: What are the complaint id of client who were born in 1931?
SQL: SELECT callcenterlogs.`complaint id` FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.year = 1931
Database: retail_complains
Note: Google account refers to email like '%@gmail.com'; percentage = divide(count(complaint id where email like '%@gmail.com') , count(complaint id)) * 100%;
Question: Calculate the percentage of complaints made by Google account client in server ZOHARI.
SQL: SELECT cast(sum(CASE WHEN client.email LIKE '%@gmail.com' THEN 1 ELSE 0 END) AS REAL) * 100 / count(client.email) FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.server = 'ZOHARI'
Database: retail_complains
Note: full name refers to first, middle, last; server time of 20 minutes and above refers to ser_time > '00:20:00';
Question: State the full name of clients with server time of 20 minutes and above.
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE strftime('%M', callcenterlogs.ser_time) > '20'
Database: retail_complains
Note: 0 priority refers to priority = 0; last name refers to last;
Question: Pick 5 clients with 0 priority and write down their last name.
SQL: SELECT client.last FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.priority = 0 LIMIT 5
Database: retail_complains
Note: first name start with alphabet "B" refers to first like 'B%';
Question: Write down the call id of clients whose first name start with alphabet "B".
SQL: SELECT callcenterlogs.call_id FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE client.first LIKE 'B%'
Database: retail_complains
Question: What is the product complained by Alexander Bronx Lewis?
SQL: SELECT DISTINCT EVENTS.product FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.first = 'Alexander' AND client.middle = 'Bronx' AND client.last = 'Lewis'
Database: retail_complains
Note: first name refers to first; male refers to sex = 'Male'; did not receive timely response refers to timely response? = 'No';
Question: State the first name of male clients who did not receive timely response from the call center.
SQL: SELECT client.first FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`timely response?` = 'No' AND client.sex = 'Male'
Database: retail_complains
Note: most complaints refers to max(client_id); elder client refers to age > 65;
Question: Which product received the most complaints from elder clients?
SQL: SELECT EVENTS.product FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.age > 65 ORDER BY client.client_id DESC LIMIT 1
Database: retail_complains
Note: about Credit Card refers to product = 'Credit Card'; teenager refers to 13 < age <= 19; adult refers to 19 < age <= 65; elder refers to age <= 65;
Question: Complaint about Credit Card mostly came from clients of which age group?
SQL: SELECT sum(CASE WHEN client.age > 13 AND client.age <= 19 THEN 1 ELSE 0 END), sum(CASE WHEN client.age > 19 AND client.age <= 65 THEN 1 ELSE 0 END) AS adult , sum(CASE WHEN client.age > 65 THEN 1 ELSE 0 END) AS elder FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.product = 'Credit card'
Database: retail_complains
Note: server time of below 10 minutes refers to ser_time < '00:10:00';
Question: List down the issues for complaint with server time of below 10 minutes.
SQL: SELECT EVENTS.issue FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE strftime('%M', callcenterlogs.ser_time) < '10'
Database: retail_complains
Note: sent via Fax refers to submitted via = 'Fax';
Question: Write down the date received of complaints sent via Fax.
SQL: SELECT callcenterlogs.`date received` FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE EVENTS.`submitted via` = 'Fax'
Database: retail_complains
Note: full name refers to first, middle, last; issue about balance transfer refers to issue = 'Balance transfer';
Question: What is the full name of clients who have issue about balance transfer?
SQL: SELECT client.first, client.middle, client.last FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.issue = 'Balance transfer'
Database: retail_complains
Note: via postal mail refers to submitted via = 'Postal mail';
Question: What is the email address of clients who submitted their complaints via postal mail?
SQL: SELECT client.email 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 where company response to consumer = 'Closed with relief'); response "Closed with relief" refers to company response to consumer = 'Closed with relief';
Question: Calculate the average age of clients whose response is "Closed with relief".
SQL: SELECT avg(client.age) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`company response to consumer` = 'Closed with relief'
Database: retail_complains
Note: average age = avg(age where type = 'TT');
Question: What is the average age of clients whose complaint type is "TT"?
SQL: SELECT avg(client.age) FROM client INNER JOIN callcenterlogs ON client.client_id = callcenterlogs.`rand client` WHERE callcenterlogs.type = 'TT'
Database: retail_complains
Note: final phone number refers to phonefinal; from 1/1/2014 to 12/30/2014 refers to date received between '2014-01-01' and '2014-12-30';
Question: Write the complaint ID, call ID, and final phone number of complaints through AVIDAN server from 1/1/2014 to 12/30/2014.
SQL: SELECT `complaint id`, call_id, phonefinal FROM callcenterlogs WHERE strftime('%Y', `date received`) = '2014' AND server = 'AVIDAN'
Database: retail_complains
Note: between 1/1/2017 and 4/1/2017 refers to date received between '2017-01-01' and '2017-04-01'; average server time refers to avg(ser_time);
Question: Between 1/1/2017 and 4/1/2017, what is the average server time of calls under the server DARMON?
SQL: SELECT avg(cast(substr(ser_time, 4, 2) AS REAL)) FROM callcenterlogs WHERE `date received` BETWEEN '2017-01-01' AND '2017-04-01'
Database: retail_complains
Note: credit card customer refers to product = 'Credit card'; about overlimit fees refers to issue = 'Overlimit fee';
Question: How many times per year does a credit card customer complain about overlimit fees?
SQL: SELECT strftime('%Y', `date received`), count(`date received`) FROM EVENTS WHERE product = 'Credit card' AND issue = 'Overlimit fee' GROUP BY strftime('%Y', `date received`) HAVING count(`date received`)
Database: retail_complains
Note: in middle Atlantic refers to division = 'middle Atlantic'; female refers to sex = 'Female'; no more than 18 refers to age < 18;
Question: Among the clients in Middle Atlantic, how many are them are female and no more than 18 years old?
SQL: SELECT count(client.sex) FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.division = 'Middle Atlantic' AND client.sex = 'Female' AND client.age < 18
Database: retail_complains
Note: full birthdate = year, month, day; youngest refers to max(year, month, day); in Indianapolis refers to city = 'Indianapolis';
Question: Give me the full birthdate, email and phone number of the youngest client in Indianapolis .
SQL: SELECT client.year, client.month, client.day, client.email, client.phone FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.city = 'Indianapolis' ORDER BY client.year DESC, client.month DESC, client.day DESC LIMIT 1
Database: retail_complains
Note: 5-star rating refers to stars = 5; in 2016 refers to date like '2016%'; most reviews refers to max(count(city));
Question: List the top five cities in terms of the number of 5-star ratings in 2016 reviews, in descending order.
SQL: SELECT district.city FROM reviews INNER JOIN district ON reviews.district_id = district.district_id WHERE reviews.stars = 5 AND reviews.date LIKE '2016%' ORDER BY reviews.date DESC LIMIT 5
Database: retail_complains
Note: longest server time refers to max(ser_time);
Question: What is the longest server time when the call is about the issue of arbitration?
SQL: SELECT max(callcenterlogs.ser_time) FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE EVENTS.issue = 'Arbitration'
Database: retail_complains
Note: social number refers to social;
Question: Give me the social number and state of the client whose phone number is 100-121-8371.
SQL: SELECT client.social, client.state FROM client INNER JOIN district ON client.district_id = district.district_id INNER JOIN state ON district.state_abbrev = state.statecode WHERE client.phone = '100-121-8371'
Database: retail_complains
Note: full name refers to first, middle, last; the Pacific refers to division = 'Pacific';
Question: List the full names and phone numbers of clients that were from the Pacific.
SQL: SELECT client.first, client.middle, client.last, client.phone FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.division = 'Pacific'
Database: retail_complains
Note: social number refers to social; longest delay = max(subtract(date sent to company, date received)); days of delay = subtract(date sent to company, date received); company's response refers to 'company response to consumer';
Question: What is the social number of the client who has the longest delay in his/her complaint? Calculate the days of delay and state the company's response to the consumer.
SQL: SELECT client.social , 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`)), EVENTS.`company response to consumer` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id ORDER BY 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`)) DESC LIMIT 1
Database: retail_complains
Note: female refers to sex = 'Female'; older than 30 refers to age > 30;
Question: How many female clients are there older than 30?
SQL: SELECT count(sex) FROM client WHERE sex = 'Female' AND age > 30
Database: retail_complains
Note: New York city refers to city = 'New York city';
Question: Please list all first and last names of clients who live in New York city.
SQL: SELECT FIRST, LAST FROM client WHERE city = 'New York City'
Database: retail_complains
Note: oldest age refers to max(age); male refers to sex = 'Male';
Question: What is the oldest age of male clients?
SQL: SELECT max(age) FROM client WHERE sex = 'Male'
Database: retail_complains
Question: Please calculate the number of clients by each division.
SQL: SELECT district.division, count(district.division) FROM client INNER JOIN district ON client.district_id = district.district_id GROUP BY district.division
Database: retail_complains
Note: female refers to sex = 'Female'; the middle Atlantic refers to division = 'middle Atlantic'; percentage = divide(count(client_id where sex = 'Female' and division = 'middle Atlantic') , count(client_id where division = 'middle Atlantic')) * 100%;
Question: What is the percentage of female clients in the Middle Atlantic?
SQL: SELECT cast(sum(CASE WHEN client.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / count(client.sex) FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.division = 'South Atlantic'
Database: retail_complains
Note: in South Atlantic refers to division = 'South Atlantic'; average age refers to avg(age);
Question: What is the average age of clients in South Atlantic?
SQL: SELECT avg(client.age) FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.division = 'South Atlantic'
Database: retail_complains
Note: least number of clients refers to min(count(client_id));
Question: Which city in the Midwest region has the least number of clients?
SQL: SELECT district.city 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' GROUP BY district.city ORDER BY count(district.city) LIMIT 1
Database: retail_complains
Note: the Northeast refers to region = 'Northeast'; Microsoft email refers to email like '%@outlook.com';
Question: How many customers in the Northeast use Microsoft email?
SQL: SELECT count(client.email) 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' AND client.email LIKE '%@outlook.com'
Database: retail_complains
Note: in North Central refers to region = 'North Central'; highest number of customers refers to max(count(client_id)); over the age of 60 refers to age > 60;
Question: Which city in West North Central has the highest number of customers over the age of 60?
SQL: SELECT district.city FROM client INNER JOIN district ON client.district_id = district.district_id WHERE district.division = 'West North Central' AND client.age > 60 GROUP BY district.city ORDER BY count(district.city) DESC LIMIT 1
Database: retail_complains
Note: percentage = divide(count(complaint id where priority = 2) , count(complaint id)) * 100%; in 2017 refers to year(date received) = 2017;
Question: What is the percentage of complaints about the late fee issue whose priority is 2 in 2017?
SQL: SELECT cast(sum(CASE WHEN callcenterlogs.priority = 2 THEN 1 ELSE 0 END) AS REAL) * 100 / count(callcenterlogs.`complaint id`) FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE strftime('%Y', callcenterlogs.`date received`) = '2017'
Database: retail_complains
Note: state refers to state_abbrev; most cities refers to max(count(city));
Question: Which state has the most cities?
SQL: SELECT state_abbrev FROM district GROUP BY state_abbrev ORDER BY count(city) DESC LIMIT 1
Database: retail_complains
Note: first name refers to first;
Question: Please give the first name and phone number of the client whose complaint id is CR0922485.
SQL: SELECT client.first, client.phone FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`complaint id` = 'CR0922485'
Database: retail_complains
Note: 7/3/2014 refers to date received = '2014-07-03';
Question: Please list the emails of the clients whose complaint date received is 7/3/2014.
SQL: SELECT client.email FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`date received` = '2014-07-03'
Database: retail_complains
Note: in 2012 refers to date received LIKE'2012%'; in Omaha refers to city = 'Omaha';
Question: In 2012, how many complaints about Credit card product came from clients in Omaha?
SQL: SELECT count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.city = 'Omaha' AND strftime('%Y', EVENTS.`date received`) = '2012' AND EVENTS.product = 'Credit card'
Database: retail_complains
Note: from 2012 to 2015 refers to date received BETWEEN 2012 AND 2015; submitted via email refers to submitted via = 'email'; female refers to sex = 'Female';
Question: From 2012 to 2015, how many complaints were submitted via email from female clients?
SQL: SELECT count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE strftime('%Y', EVENTS.`date received`) BETWEEN '2012' AND '2015' AND EVENTS.`submitted via` = 'Email' AND client.sex = 'Male'
Database: retail_complains
Note: in progress refers to company response to consumer = 'In progress';
Question: Please list all clients' phone numbers and complaint IDs which are still in progress.
SQL: SELECT client.phone, EVENTS.`complaint id` FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE EVENTS.`company response to consumer` = 'In progress'
Database: retail_complains
Note: in 2015 refers to date received LIKE'2015%'; about Billing disputes refers to issue = 'Billing disputes'; Portland refers to city = 'Portland';
Question: In 2015, how many complaints about Billing disputes were sent by clients in Portland?
SQL: SELECT count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.city = 'Portland' AND EVENTS.`date received` LIKE '2015%' AND EVENTS.issue = 'Billing disputes'
Database: retail_complains
Note: in 2014 refers to date received LIKE'2014%'; Houston refers to city = 'Houston'; delay over 5 days refers to subtract(date sent to company, date received) > 5; percentage = divide(count(complaint id where subtract(date sent to company , date received) > 5) , count(complaint id)) * 100%;
Question: In 2014, what is the percentage of complaints from consumers in Houston that the delay was over 5 days?
SQL: SELECT cast((sum(CASE WHEN strftime('%J', EVENTS.`date sent to company`) - strftime('%J', EVENTS.`date received`) > 5 THEN 1 ELSE 0 END)) AS REAL) * 100 / count(client.client_id) FROM client INNER JOIN EVENTS ON client.client_id = EVENTS.client_id WHERE client.city = 'Houston' AND strftime('%Y', EVENTS.`date received`) = '2014'
Database: retail_complains
Note: received in 2012 refers to date received LIKE '2012%'; submitted through email refers to submitted via = 'email';
Question: In the complains received in 2012, how many of them are submitted through email?
SQL: SELECT count(`submitted via`) FROM EVENTS WHERE strftime('%Y', `date received`) = '2012' AND `submitted via` = 'Email'
Database: retail_complains
Note: April 16, 2014 refers to date received = '2014-04-16'; submitted through fax refers to submitted via = 'Fax';
Question: Give the client ID of the complaint received on April 16, 2014 and submitted through fax.
SQL: SELECT EVENTS.client_id FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE EVENTS.`submitted via` = 'Fax' AND callcenterlogs.`date received` = '2014-04-16'
Database: retail_complains
Note: Eagle Capital refers to product = 'Eagle Capital'; Indianapolis refers to city = 'Indianapolis'; Indiana refers to state_abbrev = 'IN';
Question: List date of the review of the Eagle Capital from Indianapolis, Indiana.
SQL: SELECT reviews.date FROM district INNER JOIN reviews ON district.district_id = reviews.district_id WHERE reviews.product = 'Eagle Capital' AND district.city = 'Indianapolis' AND district.state_abbrev = 'IN'
Database: retail_complains
Note: in year 2015 refers to date received LIKE '2015%'; timely response refers to timely response?" = 'Yes'; closed with an explanation refers to company response to consumer = 'Closed with explanation';
Question: Among the complaints received in year 2015, what is total number of complaints timely response and closed with an explanation?
SQL: SELECT count(callcenterlogs.`complaint id`) FROM callcenterlogs INNER JOIN EVENTS ON callcenterlogs.`complaint id` = EVENTS.`complaint id` WHERE strftime('%Y', callcenterlogs.`date received`) = '2015' AND EVENTS.`timely response?` = 'Yes' AND EVENTS.`company response to consumer` = 'Closed with explanation'