Chinastark/bird_dataset huggingface dataset:
Database: retail_complains
Question: Calculate the difference in the average age of elderly and middle-aged clients in the Northeast region.
Evidence: 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;
SQL: 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'
Database: retail_complains
Question: List by their ID number the 3 longest complaints.
Evidence: ID number refers to "Complaint ID"; longest complaints refers to MAX(ser_time);
SQL: SELECT `Complaint ID` FROM callcenterlogs ORDER BY ser_time DESC LIMIT 3
Database: retail_complains
Question: How many clients have an email account other than gmail.com?
Evidence: email account other than gmail.com refers to email not like '%@gmail.com';
SQL: SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com'
Database: retail_complains
Question: Identify by their ID all clients who did not give their consent permission.
Evidence: did not give their consent permission refers to Consumer consent provided is null, 'N/A', or empty;
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
Question: List by their ID the complaints received by the company on 25/09/2014 that took the longest.
Evidence: 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"));
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
Question: How many complaints are not in process with an agent?
Evidence: not in process with an agent refers to outcome ! = 'AGENT';
SQL: SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'
Database: retail_complains
Question: How many Credit Card complaints did Sharon handle?
Evidence: Credit Card refers to Product = 'Credit Card'; Sharon refers to server = 'SHARON';
SQL: 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'
Database: retail_complains
Question: In which region have the most 1-star reviews been done?
Evidence: most 1-star reviews refers to MAX(COUNT(stars = 1));
SQL: 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
Database: retail_complains
Question: In what years were the clients who demanded more problems with Certificate of deposit born?
Evidence: more problems with Certificate refers to MAX(COUNT("Sub-product" = '(CD) Certificate of deposit'));
SQL: 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
Database: retail_complains
Question: How many cases of billing dispute issues occurred in the Mountain division?
Evidence: billing dispute refers to issue = 'Billing disputes';
SQL: 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'
Database: retail_complains
Question: How many male clients are from the state of Massachusetts?
Evidence: male refers to sex = 'Male';
SQL: 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'
Database: retail_complains
Question: Lists the last name of all clients who made a PS-type complaint and were served by TOVA.
Evidence: PS-type complaint refers to type = 'PS'; served by refers to server;


SQL: SELECT t1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'PS' AND T2.server = 'TOVA'
Database: retail_complains
Question: How many clients under the age of 35 gave Eagle National Mortgage 1 star?
Evidence: age < 35; Eagle National Mortgage refers to Product = 'Eagle National Mortgage';
SQL: SELECT COUNT(T2.age) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle National Mortgage' AND T1.Stars = 1 AND T2.age < 35
Database: retail_complains
Question: How many male clients born in the year 1977 were given priority 0 in their complaints?
Evidence: male refers to sex = 'Male';
SQL: SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.sex = 'Male' AND T2.priority = 0 AND T1.year = 1997
Database: retail_complains
Question: List by name all customers who provided consent for the tag Older American.
Evidence: name refers to first; provided consent refers to "Consumer consent provided?" not in ('N/A', null, 'empty');
SQL: 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.Tags = 'Older American' AND T2.`Consumer consent provided?` != 'N/A' AND T2.`Consumer consent provided?` IS NOT NULL AND T2.`Consumer consent provided?` != ''
Database: retail_complains
Question: What is the name of the state in which there have been the largest number of complaints with priority 0?
Evidence: largest number of complaints refers to MAX(COUNT("Complaint ID") WHERE priority = 0);
SQL: SELECT T2.state 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 T1.priority = 0 GROUP BY T2.state ORDER BY COUNT(T2.state) DESC LIMIT 1
Database: retail_complains
Question: How many complaints made by women and served after 3 pm received a timely response from the company?
Evidence: 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';
SQL: SELECT COUNT(T1.`Complaint ID`) 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.sex = 'Female' AND T1.ser_start BETWEEN '15:00:01' AND '23:59:59' AND T3.`Timely response?` = 'Yes'
Database: retail_complains
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?
Evidence: 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";
SQL: SELECT COUNT(T1.`Complaint ID`) FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time < '00:05:00' AND T1.server = 'DORIT' AND T2.`Submitted via` = 'Phone' AND T2.`Company response to consumer` = 'Closed with explanation'
Database: retail_complains
Question: How many clients with the last name Alvarado are from Maryland?
Evidence: The abbreviation of Maryland is 'MD';
SQL: SELECT COUNT(T2.client_id) FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T1.state_abbrev = T3.StateCode WHERE T2.last = 'Alvarado' AND T2.state = 'MD'
Database: retail_complains
Question: How many reviews by people between 30 and 50 years include the word 'great'?
Evidence: between 30 and 50 years refers to age BETWEEN 30 AND 50; include the word great refers to Review like '%Great%';
SQL: SELECT COUNT(T1.Reviews) FROM reviews AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T2.age BETWEEN 30 AND 50 AND T1.Reviews LIKE '%great%'
Database: retail_complains
Question: What is the full address of the customers who, having received a timely response from the company, have dispute about that response?
Evidence: full address = address_1, address_2; received a timely response refers to Timely response? = 'Yes'; have dispute refers to "Consumer disputed?" = 'Yes';
SQL: SELECT T1.address_1, T1.address_2 FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Timely response?` = 'Yes' AND T2.`Consumer disputed?` = 'Yes'
Database: retail_complains
Question: How many complaints from female clients born in the year 2000 were not sent through the web?
Evidence: female refers to sex = 'Female'; sent through refers to "Submitted via"; not sent through web refers to "Submitted via" ! = 'Web';

SQL: SELECT COUNT(T2.`Submitted via`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T1.year = 2000 AND T2.`Submitted via` != 'Web'
Database: retail_complains
Question: List all the complaints narratives made by the customer named Brenda and last name Mayer.
Evidence: complaints narratives refers to "Consumer complaint narrative";
SQL: SELECT T2.`Consumer complaint narrative` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Brenda' AND T1.last = 'Mayer'
Database: retail_complains
Question: How many complaints from customers with a gmail.com email were received by the company in February 2017?
Evidence: gmail.com email refers to email like '%gmail.com'; in February 2017 refers to "Date received" BETWEEN '2017-01-02' AND '2017-02-28';
SQL: SELECT COUNT(T1.email) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE (T2.`Date received` LIKE '2017-02%' OR T2.`Date received` LIKE '2017-01%') AND T1.email LIKE '%@gmail.com'
Database: retail_complains
Question: What is the average number of stars given by Oregon clients in their reviews?
Evidence: average = DIVIDE(SUM(State = 'Oregon'), COUNT(district_id)); Oregon refers to state = 'Oregon';
SQL: SELECT CAST(SUM(T3.Stars) AS REAL) / COUNT(T3.Stars) AS average FROM state AS T1 INNER JOIN district AS T2 ON T1.StateCode = T2.state_abbrev INNER JOIN reviews AS T3 ON T2.district_id = T3.district_id WHERE T1.State = 'Oregon'
Database: retail_complains
Question: What percentage of clients who sent their complaints by postal mail are age 50 and older?
Evidence: percentage = MULTIPLY(DIVIDE(SUM("Submitted via" = 'Postal mail'), COUNT(client_id)), 1.0); sent their complaints by refers to "Submitted via"; age > 50;
SQL: SELECT CAST(SUM(CASE WHEN T1.age > 50 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.`Submitted via`) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Submitted via` = 'Postal mail'
Database: retail_complains
Question: What is the average age of Norwalk clients?
Evidence: average age = AVG(age); Norwalk refers to city = 'Norwalk';
SQL: SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T1.age) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Norwalk'
Database: retail_complains
Question: How many clients who live in Kansas City provided a 1-star review?
Evidence: 1-star review refers stars = 1;
SQL: SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Kansas City' AND T1.Stars = 1
Database: retail_complains
Question: Which state has the highest number of clients who gave a 5-star review?
Evidence: highest number of clients refers to MAX(COUNT(client_id)); 5-star review refers to stars = 5;
SQL: SELECT T2.state_abbrev FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 5 GROUP BY T2.state_abbrev ORDER BY COUNT(T2.state_abbrev) DESC LIMIT 1
Database: retail_complains
Question: Which region does Noah Thompson live in?
SQL: SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.first = 'Noah' AND T1.last = 'Thompson'
Database: retail_complains
Question: How did Kyran Muller submit his complaint?
Evidence: how it was submitted refers to "Submitted via";
SQL: SELECT DISTINCT T2.`Submitted via` FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kyran' AND T1.last = 'Muller'
Database: retail_complains
Question: What are the products that people who were born after 2005 complain about?
Evidence: year > 2005;
SQL: SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year > 2005
Database: retail_complains
Question: How long was Kendall Allen's complaint about her credit card?
Evidence: how long refers to ser_time; credit card refers to Product = 'Credit Card';
SQL: SELECT T3.ser_time FROM events AS T1 INNER JOIN client AS T2 ON T1.Client_ID = T2.client_id INNER JOIN callcenterlogs AS T3 ON T1.`Complaint ID` = T3.`Complaint ID` WHERE T2.first = 'Kendall' AND T2.last = 'Allen' AND T2.sex = 'Female' AND T1.Product = 'Credit card'
Database: retail_complains
Question: What was the issue that the client with the longest server time faced?
Evidence: longest server time refers to MAX(ser_time);
SQL: SELECT T2.Issue FROM callcenterlogs AS T1 INNER JOIN events AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.ser_time = ( SELECT MAX(ser_time) FROM callcenterlogs )
Database: retail_complains
Question: How many clients who live in New York City submitted their complaints via fax?
Evidence: submitted complaints via fax refers to "Submitted via" = 'Fax';
SQL: SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.city = 'New York City' AND T2.`Submitted via` = 'Fax'
Database: retail_complains
Question: What is the percentage of male clients complaining about their credit cards?
Evidence: percentage = MULTIPLY(DIVIDE(SUM(sex = 'Male'), COUNT(client_id)), 1.0); male refers to sex = 'Male'; credit cards refers to Product = 'Credit card';
SQL: SELECT CAST(SUM(CASE WHEN T1.sex = 'Male' 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.Product = 'Credit card'
Database: retail_complains
Question: Please list any two clients with their full names who have been tagged as "Older American" by the company without seeking their permission.
Evidence: full names = first, middle, last; without seeking their permission refers to "Consumer consent provided?" in (null, 'N/A' or 'empty');
SQL: 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.Tags = 'Older American' AND T2.`Consumer consent provided?` IN (NULL, 'N/A', '') LIMIT 2
Database: retail_complains
Question: What is the birth date of the youngest client?
Evidence: birth date refers to year, month, day; youngest client refers to max(year, month, day)
SQL: SELECT day, month, year FROM client ORDER BY year DESC, month DESC, day DESC LIMIT 1
Database: retail_complains
Question: How many times does the consumer have no dispute over a non-timely response from the company?
Evidence: no dispute refers to Consumer disputed? = 'No'; non-timely response refers to Timely response? = 'No'
SQL: SELECT COUNT(`Timely response?`) FROM events WHERE `Timely response?` = 'No' AND `Consumer disputed?` = 'No'
Database: retail_complains
Question: How many of the complaints are longer than 15 minutes?
Evidence: longer than 15 minutes refers to ser_time > '00:15:00'
SQL: SELECT COUNT(ser_time) FROM callcenterlogs WHERE strftime('%M', ser_time) > '15'
Database: retail_complains
Question: What is the most common issue for the highest priority complaints?
Evidence: most common refers to max(count(issue)); highest priority refers to priority = 2
SQL: SELECT T1.Issue FROM events AS T1 INNER JOIN callcenterlogs AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T2.priority = 2 GROUP BY T1.Issue ORDER BY COUNT(T1.Issue) DESC LIMIT 1
Database: retail_complains
Question: List the full names of all clients who live in the Pacific division.
Evidence: full name refers to first, last
SQL: SELECT T2.first, T2.middle, T2.last FROM district AS T1 INNER JOIN client AS T2 ON T1.district_id = T2.district_id WHERE T1.division = 'Pacific'
Database: retail_complains
Question: What is the social number of the person who made the most complaints?
Evidence: social number refers to social; most complaints refers to max(count(event.Client_ID))
SQL: SELECT T1.social FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID GROUP BY T1.client_id ORDER BY COUNT(T1.client_id) DESC LIMIT 1
Database: retail_complains
Question: Which is the city where most of the 1 star reviews come from?
Evidence: most refers to max(count(state_abbrev)); 1 star review refers to Stars = 1
SQL: SELECT T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Stars = 1 GROUP BY T2.city ORDER BY COUNT(T2.city) DESC LIMIT 1
Database: retail_complains
Question: What is the address of the client who made a complaint via postal mail on March 14, 2012?
Evidence: 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'
SQL: SELECT T1.address_1, T1.address_2 FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Date received` = '2012-03-14' AND T2.`Submitted via` = 'Postal mail'
Database: retail_complains
Question: Among the female clients, how many of them have a complaint with a priority of 1?
Evidence: female refers to sex = 'Female'
SQL: SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.sex = 'Female' AND T2.priority = 1
Database: retail_complains
Question: List all the server of the phone complaints with a late response from the company.
Evidence: phone complaint refers to Submitted via = 'Phone'; late response refers to Timely response? = 'No'
SQL: SELECT DISTINCT T2.server FROM events AS T1 INNER JOIN callcenterlogs AS T2 ON T1.`Complaint ID` = T2.`Complaint ID` WHERE T1.`Submitted via` = 'Phone' AND T1.`Timely response?` = 'No'
Database: retail_complains
Question: List all the issues of the complaints made by Kaitlyn Eliza Elliott.
SQL: SELECT DISTINCT T2.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Kaitlyn' AND T1.middle = 'Eliza' AND T1.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 T3.state 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 T3.email = 'skylar.ramirez@gmail.com'
Database: retail_complains
Question: Which region has the second most clients?
Evidence: region refers to division; second most refers to second max(client_id)
SQL: SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id GROUP BY T2.division ORDER BY COUNT(T2.division) DESC LIMIT 1, 1
Database: retail_complains
Question: Who is the owner of the final phone number for the complaints on server "MORIAH" on 9/11/2013?
Evidence: owner refers to first, middle, last; on 9/11/2013 refers to Date received = '2013-09-11'
SQL: 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.server = 'MORIAH' AND T2.`Date received` = '2013-09-11'
Database: retail_complains
Question: Compute the average time in minute for each age group
Evidence: 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)))
SQL: SELECT CAST(SUM(CASE WHEN T1.age > 13 AND T1.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 T1.age > 13 AND T1.age <= 19 THEN 1 ELSE 0 END) AS teenagerAverageMins, CAST(SUM(CASE WHEN T1.age > 19 AND T1.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 T1.age > 19 AND T1.age <= 65 THEN 1 ELSE 0 END) AS adultAverageMins , CAST(SUM(CASE WHEN T1.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 T1.age > 65 THEN 1 ELSE 0 END) AS elderAverageMins FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client`
Database: retail_complains
Question: What percentage of complaints are from the elderly?
Evidence: elder refers to age < = 65; percentage refers to divide(sum(age < = 65) , count(client_id)) * 100%
SQL: SELECT CAST(SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.age) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID
Database: retail_complains
Question: Calculate the percentage of male clients from Indianapolis City.
Evidence: 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%
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
Question: Among the teenager clients who use Google account and Microsoft account, which group of client is more than the other?
Evidence: teenager refers to 13 < age < = 19; Google account refers to email like '%@gmail.com'; Microsoft account refers to email like '%@outlook.com'
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
Question: What is the full name of client whose email address is emily.garcia43@outlook.com?
Evidence: full name refers to first middle last
SQL: SELECT first, middle, last FROM client WHERE email = 'emily.garcia43@outlook.com'
Database: retail_complains
Question: What is the first name of clients who have the highest priority?
Evidence: first name refers to first; highest priority refers to priority = 2
SQL: SELECT T1.first FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.priority = ( SELECT MAX(priority) FROM callcenterlogs )
Database: retail_complains
Question: List down the email of client whose complaint is type "PS".
SQL: SELECT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'PS'
Database: retail_complains
Question: Among the elderlies, state the last name of whose complaint is handled in server YIFAT?
Evidence: elder refers to age < = 65; last name refers to last
SQL: SELECT T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.age > 65 AND T2.server = 'YIFAT'