db_id
stringclasses
68 values
question
stringlengths
24
325
evidence
stringlengths
0
580
SQL
stringlengths
23
728
book_publishing_company
How many publishers are in the USA?
SELECT COUNT(pub_id) FROM publishers WHERE country = 'USA'
book_publishing_company
Please list the first names of the employees who work as Managing Editor.
Managing Editor is a job description which refers to job_desc
SELECT T1.fname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T2.job_desc = 'Managing Editor'
book_publishing_company
What is the highest level of job to get to for the employee who got hired the earliest?
highest job level refers to MAX(job_lvl); hired the earliest refers to MIN(hire_date)
SELECT T2.max_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.hire_date LIMIT 1
book_publishing_company
In which city is the store with the highest total sales quantity located?
qty is abbreviation for quantity; highest sales quantity refers to MAX(qty)
SELECT T2.city FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id GROUP BY T2.city ORDER BY SUM(T1.qty) DESC LIMIT 1
book_publishing_company
What is the price of the book that sells the best?
qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)
SELECT T2.price FROM sales AS T1 INNER JOIN titles AS T2 ON T1.title_id = T2.title_id ORDER BY T1.qty DESC LIMIT 1
book_publishing_company
Please list the stores that ordered the book "Life Without Fear".
store name refers to stor_name
SELECT T2.stor_name FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T3.title = 'Life Without Fear'
book_publishing_company
Among the stores that have ordered the book "Life Without Fear", how many of them are located in Massachusetts?
Massachusetts is a state
SELECT COUNT(T1.stor_id) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts'
book_publishing_company
In which country is the publisher of the book "Life Without Fear" located?
Life Without Fear is book title
SELECT T2.country FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Life Without Fear'
book_publishing_company
What is the publisher that has published the most expensive book?
most expensive book refers to MAX(price)
SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id ORDER BY T1.price DESC LIMIT 1
book_publishing_company
Among the publishers in the USA, how many of them have published books that are over $15?
are over $15 refers to price>15
SELECT COUNT(DISTINCT T1.pub_id) FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.country = 'USA' AND T1.price > 15
book_publishing_company
Please give more detailed information about the first three books that sell the best.
qty is abbreviation for quantity; sells the best mean with the most sales quantity; MAX(qty)
SELECT T1.notes FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id ORDER BY T2.qty DESC LIMIT 3
book_publishing_company
What is the average quantity of each order for the book "Life Without Fear"?
qty is abbreviation for quantity; average quantity order = AVG(qty)
SELECT CAST(SUM(T2.qty) AS REAL) / COUNT(T1.title_id) FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id WHERE T1.title = 'Life Without Fear'
book_publishing_company
What is the average level employees working as Managing Editor are at? How many levels are there between the average level and the highest level?
Managing Editor is a job description which refers to job_desc; job level refers to job_lvl; highest level job refers to max_lvl; levels between the average level and the highest level = SUBTRACT(max_lvl; AVG(job_lvl))
SELECT AVG(T2.job_lvl), T1.max_lvl - AVG(T2.job_lvl) FROM jobs AS T1 INNER JOIN employee AS T2 ON T1.job_id = T2.job_id WHERE T1.job_desc = 'Managing Editor' GROUP BY T2.job_id, T1.max_lvl
book_publishing_company
Which one is the cheapest business book?
business books refers to type = 'business'; cheapest book refers to MIN(price)
SELECT title FROM titles WHERE type = 'business' ORDER BY price LIMIT 1
book_publishing_company
Which type of book had the most pre-paid amount?
most pre-paid amount refers to MAX(advance)
SELECT type FROM titles ORDER BY advance DESC LIMIT 1
book_publishing_company
Which job level is O'Rourke at?
job level refers to job_lvl
SELECT job_lvl FROM employee WHERE lname = 'O''Rourke'
book_publishing_company
Show me the employ id of the highest employee who doesn't have a middle name.
highest employee refers to employee with the highest job level; MAX(job_lvl)
SELECT emp_id FROM employee WHERE minit = '' ORDER BY job_lvl DESC LIMIT 1
book_publishing_company
Is the author of "Sushi, Anyone?" on the contract?
contract = 1 means on contract; contract = 0 means not on contract
SELECT T1.contract FROM authors AS T1 INNER JOIN titleauthor AS T2 ON T1.au_id = T2.au_id INNER JOIN titles AS T3 ON T2.title_id = T3.title_id WHERE T3.title = 'Sushi, Anyone?'
book_publishing_company
Which publisher had the highest job level? Give his/her full name.
highest job level refers to MAX(job_lvl)
SELECT T1.fname, T1.minit, T1.lname FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id ORDER BY T1.job_lvl DESC LIMIT 1
book_publishing_company
What's Pedro S Afonso's job title?
job title means job description which refers to job_desc
SELECT T2.job_desc FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Pedro' AND T1.minit = 'S' AND T1.lname = 'Afonso'
book_publishing_company
How many levels are there left for Diego W Roel to reach if he/she could go to the max level for his/her position?
max level for his position refers to max_lvl; job level refers to job_lvl; level left to reach the max = SUBTRACT(max_lvl, job_lvl)
SELECT T2.max_lvl - T1.job_lvl FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.fname = 'Diego' AND T1.minit = 'W' AND T1.lname = 'Roel'
book_publishing_company
What's the publisher of the book "Silicon Valley Gastronomic Treats"? Give the publisher's name.
publisher name refers to pub_name; Silicon Valley Gastronomic Treats is the title of a book
SELECT T2.pub_name FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.title = 'Silicon Valley Gastronomic Treats'
book_publishing_company
Which city did Victoria P Ashworth work in?
SELECT T2.city FROM employee AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.fname = 'Victoria' AND T1.minit = 'P' AND T1.lname = 'Ashworth'
book_publishing_company
How many sales did the store in Remulade make?
Remulade is a city; sales in the store refers to ord_num
SELECT COUNT(T1.ord_num) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id WHERE T2.city = 'Remulade'
book_publishing_company
Among all the employees, how many percent more for the publishers than designers?
publisher and designer are job descriptions which refers to job_desc; percentage more = 100*(SUBTRACT(SUM(CASE WHERE job_desc = 'publisher), SUM(CASE WHERE job_desc = 'designer'))
SELECT CAST(SUM(CASE WHEN T2.job_desc = 'publisher' THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.job_desc = 'designer' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.job_id) FROM employee AS T1 INNER JOIN jobs AS T2 ON T1.job_id = T2.job_id
book_publishing_company
Which titles has above average royalty rate? Give those title's name, type and price?
average royalty rate = DIVIDE(SUM(royalty), COUNT(title_id))
SELECT DISTINCT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN roysched AS T2 ON T1.title_id = T2.title_id WHERE T2.royalty > ( SELECT CAST(SUM(royalty) AS REAL) / COUNT(title_id) FROM roysched )
book_publishing_company
List the title name, type, and price of the titles published by New Moon Books. Arrange the list in ascending order of price.
Eric the Read Books is a publisher which refers to pub_name;
SELECT T1.title, T1.type, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T2.pub_name = 'New Moon Books' ORDER BY T1.price
book_publishing_company
In the books published by US publishers, which book has the highest royalty? List these books in the descending order of royalty.
US publisher refers publisher in the US where country = 'USA';
SELECT T1.title FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id INNER JOIN roysched AS T3 ON T1.title_id = T3.title_id WHERE T2.country = 'USA' ORDER BY T1.royalty DESC
book_publishing_company
Calculate the average level difference between the Marketing editors hired by the US and non-US publishers?
Marketing manager is a job description which refers to job_desc; US publisher refers publisher in the US where country = 'USA'; non-US publishers refers publisher not in the US where country! = 'USA'; job level refers to job_lvl; average level = AVG(job_lvl)
SELECT (CAST(SUM(CASE WHEN T1.country = 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country = 'USA' THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.country != 'USA' THEN job_lvl ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.country != 'USA' THEN 1 ELSE 0 END)) FROM publishers AS T1 INNER JOIN employee AS T2 ON T1.pub_id = T2.pub_id INNER JOIN jobs AS T3 ON T2.job_id = T3.job_id WHERE T3.job_desc = 'Managing Editor'
book_publishing_company
Which title is about helpful hints on how to use your electronic resources, which publisher published it and what is the price of this book?
publisher refers to pub_name; about the title refers to notes
SELECT T1.title, T2.pub_name, T1.price FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Helpful hints on how to use your electronic resources to the best advantage.'
book_publishing_company
Of the titles, which title is about the Carefully researched study of the effects of strong emotions on the body, which state-based publisher published this book, and what is the year-to-date sale?
year to date sales refers to ytd_sales; about the title refers to notes
SELECT T1.title, T2.pub_name, T1.ytd_sales FROM titles AS T1 INNER JOIN publishers AS T2 ON T1.pub_id = T2.pub_id WHERE T1.notes = 'Carefully researched study of the effects of strong emotions on the body. Metabolic charts included.'
book_publishing_company
Name the top five titles that sold more than average and list them in descending order of the number of sales in California stores?
qty is abbreviation for quantity; sold more than average refers to qty > AVG(qty); california refers to state = 'CA"
SELECT T1.title FROM titles AS T1 INNER JOIN sales AS T2 ON T1.title_id = T2.title_id INNER JOIN publishers AS T3 ON T1.pub_id = T3.pub_id WHERE T2.qty > ( SELECT CAST(SUM(qty) AS REAL) / COUNT(title_id) FROM sales ) AND T3.state = 'CA' ORDER BY T2.qty DESC LIMIT 5
retail_complains
Please list the full names of all the male clients born after the year 1990.
full names = first, middle, last; male refers to sex = 'Male'; year > 1990;
SELECT first, middle, last FROM client WHERE year > 1990
retail_complains
How many complaints have the client Diesel Galloway filed?
SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Diesel' AND T1.last = 'Galloway'
retail_complains
Among all the clients from the New York city, how many of them have filed a complaint on the issue of Deposits and withdrawals?
SELECT COUNT(T2.Issue) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Issue = 'Deposits and withdrawals' AND T1.city = 'New York City'
retail_complains
Which division is Diesel Galloway in?
SELECT T2.division FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.first = 'Diesel' AND T1.last = 'Galloway'
retail_complains
Please list the full names of all the male clients in the Pacific division.
full names = first, middle, last; male refers to sex = 'Male';
SELECT T1.first, T1.middle, T1.last FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific' AND T1.sex = 'Male'
retail_complains
Which state does the owner of "wyatt.collins@gmail.com" live in? Give the full name of the state.
full name of the state refers to state_name;
SELECT T1.state FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.email = 'wyatt.collins@gmail.com'
retail_complains
Which district did the review on 2018/9/11 come from? Give the name of the city.
on 2018/9/11 refers to Date = '2017-07-22';
SELECT T2.district_id, T2.city FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Date = '2018-09-11'
retail_complains
What was the review context from Jacksonville on 2017/7/22?
Jacksonville refers to city = 'Jacksonville'; on 2017/7/22 refers to Date = '2017-07-22';
SELECT T1.Reviews FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Jacksonville' AND T1.Date = '2017-07-22'
retail_complains
Which product received a review from Indianapolis on 2016/10/7?
Indianapolis refers to state = 'Indianapolis'; on 2016/10/7 refers to Date = '2013-04-04';
SELECT T1.Product FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Indianapolis' AND T1.Date = '2016-10-07'
retail_complains
How many stars did "Eagle Capital" received from Little Rock on 2013/4/4?
Eagle Capital refers to Product = 'Eagle Capital'; Little Rock is a city; on 2013/4/4 refers to Date = '2013-04-04';
SELECT COUNT(T1.Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T2.city = 'Little Rock' AND T1.Date = '2013-04-04'
retail_complains
Please list the full name, date of birth, and email id of the elderly clients in descending order of age.
full name = first, middle, last; date of birth = year, month, day; elderly clients refers to age > 65;
SELECT first, middle, last, year, month , day, email FROM client WHERE age > 65 ORDER BY age DESC
retail_complains
List all the states in the South region.
SELECT state FROM state WHERE Region = 'South'
retail_complains
Calculate the average age of clients from the Midwest region.
average age = AVG(age);
SELECT CAST(SUM(T1.age) AS REAL) / COUNT(T3.Region) AS average FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest'
retail_complains
Find and list the names of districts which has below-average stars for Eagle Capital.
below average = AVG(stars) < Stars; Eagle Capital refers to Product = 'Eagle Capital';
SELECT T2.division FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.Product = 'Eagle Capital' AND T1.Stars > ( SELECT AVG(Stars) FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id )
retail_complains
In the calls from the mountain division, how many are from teenage clients?
teenage refers to age BETWEEN 12 AND 20;
SELECT COUNT(T1.age) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T1.age BETWEEN 12 AND 20 AND T2.division = 'Mountain'
retail_complains
What is the number of complaints related to Credit cards came from female clients?
Credit cards refers to Product = 'Credit card'; female refers to sex = 'female';
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Female' AND T2.Product = 'Credit card'
retail_complains
Find the number of service members who complained in Syracuse.
service members refers to client.client_id; Syracuse refers to city = 'Syracuse';
SELECT COUNT(T1.client_id) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Tags = 'Servicemember' AND T1.city = 'Syracuse'
retail_complains
Calculate the difference in the average age of elderly and middle-aged clients in the Northeast region.
difference in the average = SUBTRACT(AVG(age BETWEEN 35 AND 55), AVG( age > 65)); elderly refers to age > 65; middle-aged refers to age BETWEEN 35 AND 55;
SELECT (CAST(SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age BETWEEN 35 AND 55 THEN 1 ELSE 0 END)) - (CAST(SUM(CASE WHEN T1.age > 65 THEN T1.age ELSE 0 END) AS REAL) / SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END)) AS difference FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Northeast'
retail_complains
How many clients have an email account other than gmail.com?
email account other than gmail.com refers to email not like '%@gmail.com';
SELECT COUNT(email) FROM client WHERE email NOT LIKE '%@gmail.com'
retail_complains
How many complaints are not in process with an agent?
not in process with an agent refers to outcome ! = 'AGENT';
SELECT COUNT(outcome) FROM callcenterlogs WHERE outcome != 'AGENT'
retail_complains
In which region have the most 1-star reviews been done?
most 1-star reviews refers to MAX(COUNT(stars = 1));
SELECT T3.Region FROM reviews AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T1.Stars = 1 GROUP BY T3.Region ORDER BY COUNT(T3.Region) DESC LIMIT 1
retail_complains
How many cases of billing dispute issues occurred in the Mountain division?
billing dispute refers to issue = 'Billing disputes';
SELECT COUNT(T1.Issue) FROM events AS T1 INNER JOIN client AS T2 ON T1.Client_ID = T2.client_id INNER JOIN district AS T3 ON T2.district_id = T3.district_id WHERE T1.Issue = 'Billing disputes' AND T3.division = 'Mountain'
retail_complains
How many male clients are from the state of Massachusetts?
male refers to sex = 'Male';
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'
retail_complains
How many clients under the age of 35 gave Eagle National Mortgage 1 star?
age < 35; Eagle National Mortgage refers to Product = 'Eagle National Mortgage';
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
retail_complains
How many clients with the last name Alvarado are from Maryland?
The abbreviation of Maryland is 'MD';
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'
retail_complains
How many reviews by people between 30 and 50 years include the word 'great'?
between 30 and 50 years refers to age BETWEEN 30 AND 50; include the word great refers to Review like '%Great%';
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%'
retail_complains
What is the average number of stars given by Oregon clients in their reviews?
average = DIVIDE(SUM(State = 'Oregon'), COUNT(district_id)); Oregon refers to state = 'Oregon';
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'
retail_complains
What is the average age of Norwalk clients?
average age = AVG(age); Norwalk refers to city = 'Norwalk';
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'
retail_complains
How many clients who live in Kansas City provided a 1-star review?
1-star review refers stars = 1;
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
retail_complains
Which state has the highest number of clients who gave a 5-star review?
highest number of clients refers to MAX(COUNT(client_id)); 5-star review refers to stars = 5;
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
retail_complains
Which region does Noah Thompson live in?
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'
retail_complains
What are the products that people who were born after 2005 complain about?
year > 2005;
SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.year > 2005
retail_complains
What is the percentage of male clients complaining about their credit cards?
percentage = MULTIPLY(DIVIDE(SUM(sex = 'Male'), COUNT(client_id)), 1.0); male refers to sex = 'Male'; credit cards refers to Product = 'Credit card';
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'
retail_complains
What is the birth date of the youngest client?
birth date refers to year, month, day; youngest client refers to max(year, month, day)
SELECT day, month, year FROM client ORDER BY year DESC, month DESC, day DESC LIMIT 1
retail_complains
List the full names of all clients who live in the Pacific division.
full name refers to first, last
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'
retail_complains
What is the social number of the person who made the most complaints?
social number refers to social; most complaints refers to max(count(event.Client_ID))
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
retail_complains
Which is the city where most of the 1 star reviews come from?
most refers to max(count(state_abbrev)); 1 star review refers to Stars = 1
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
retail_complains
List all the issues of the complaints made by Kaitlyn Eliza Elliott.
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'
retail_complains
What is the name of the state that the client with the email "skylar.ramirez@gmail.com" lives in?
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'
retail_complains
What percentage of complaints are from the elderly?
elder refers to age < = 65; percentage refers to divide(sum(age < = 65) , count(client_id)) * 100%
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
retail_complains
Calculate the percentage of male clients from Indianapolis City.
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%
SELECT CAST(SUM(CASE WHEN sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(client_id) FROM client WHERE city = 'Indianapolis'
retail_complains
Among the teenager clients who use Google account and Microsoft account, which group of client is more than the other?
teenager refers to 13 < age < = 19; Google account refers to email like '%@gmail.com'; Microsoft account refers to email like '%@outlook.com'
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
retail_complains
What is the full name of client whose email address is emily.garcia43@outlook.com?
full name refers to first middle last
SELECT first, middle, last FROM client WHERE email = 'emily.garcia43@outlook.com'
retail_complains
What is the product complained by Alexander Bronx Lewis?
SELECT DISTINCT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.first = 'Alexander' AND T1.middle = 'Bronx' AND T1.last = 'Lewis'
retail_complains
Which product received the most complaints from elder clients?
most complaints refers to max(client_id); elder client refers to age > 65
SELECT T2.Product FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.age > 65 ORDER BY T1.client_id DESC LIMIT 1
retail_complains
Complaint about Credit Card mostly came from clients of which age group?
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
SELECT SUM(CASE WHEN T1.age > 13 AND T1.age <= 19 THEN 1 ELSE 0 END), SUM(CASE WHEN T1.age > 19 AND T1.age <= 65 THEN 1 ELSE 0 END) AS adult , SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS elder FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card'
retail_complains
What is the full name of clients who have issue about balance transfer?
full name refers to first, middle, last; issue about balance transfer refers to Issue = 'Balance transfer'
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.Issue = 'Balance transfer'
retail_complains
Among the clients in Middle Atlantic, how many are them are female and no more than 18 years old?
in Middle Atlantic refers to division = 'Middle Atlantic'; female refers to sex = 'Female'; no more than 18 refers to age < 18
SELECT COUNT(T1.sex) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Middle Atlantic' AND T1.sex = 'Female' AND T1.age < 18
retail_complains
Give me the full birthdate, email and phone number of the youngest client in Indianapolis .
full birthdate = year, month, day; youngest refers to max(year, month, day); in Indianapolis refers to city = 'Indianapolis'
SELECT T1.year, T1.month, T1.day, T1.email, T1.phone FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.city = 'Indianapolis' ORDER BY T1.year DESC, T1.month DESC, T1.day DESC LIMIT 1
retail_complains
Give me the social number and state of the client whose phone number is 100-121-8371.
social number refers to social
SELECT T1.social, T1.state 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 T1.phone = '100-121-8371'
retail_complains
List the full names and phone numbers of clients that were from the Pacific.
full name refers to first, middle, last; the Pacific refers to division = 'Pacific'
SELECT T1.first, T1.middle, T1.last, T1.phone FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'Pacific'
retail_complains
How many female clients are there older than 30?
female refers to sex = 'Female'; older than 30 refers to age > 30
SELECT COUNT(sex) FROM client WHERE sex = 'Female' AND age > 30
retail_complains
Please list all first and last names of clients who live in New York city.
New York City refers to city = 'New York City'
SELECT first, last FROM client WHERE city = 'New York City'
retail_complains
What is the oldest age of male clients?
oldest age refers to max(age); male refers to sex = 'Male'
SELECT MAX(age) FROM client WHERE sex = 'Male'
retail_complains
Please calculate the number of clients by each division.
SELECT T2.division, COUNT(T2.division) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id GROUP BY T2.division
retail_complains
What is the percentage of female clients in the Middle Atlantic?
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%
SELECT CAST(SUM(CASE WHEN T1.sex = 'Female' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.sex) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'South Atlantic'
retail_complains
What is the average age of clients in South Atlantic?
in South Atlantic refers to division = 'South Atlantic'; average age refers to avg(age)
SELECT AVG(T1.age) FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'South Atlantic'
retail_complains
Which city in the Midwest region has the least number of clients?
least number of clients refers to min(count(client_id))
SELECT T2.city FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id INNER JOIN state AS T3 ON T2.state_abbrev = T3.StateCode WHERE T3.Region = 'Midwest' GROUP BY T2.city ORDER BY COUNT(T2.city) LIMIT 1
retail_complains
How many customers in the Northeast use Microsoft email?
the Northeast refers to Region = 'Northeast'; Microsoft email refers to email like '%@outlook.com'
SELECT COUNT(T1.email) 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' AND T1.email LIKE '%@outlook.com'
retail_complains
Which city in West North Central has the highest number of customers over the age of 60?
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
SELECT T2.city FROM client AS T1 INNER JOIN district AS T2 ON T1.district_id = T2.district_id WHERE T2.division = 'West North Central' AND T1.age > 60 GROUP BY T2.city ORDER BY COUNT(T2.city) DESC LIMIT 1
retail_complains
Which state has the most cities?
state refers to state_abbrev; most cities refers to max(count(city))
SELECT state_abbrev FROM district GROUP BY state_abbrev ORDER BY COUNT(city) DESC LIMIT 1
retail_complains
List date of the review of the Eagle Capital from Indianapolis, Indiana.
Eagle Capital refers to Product = 'Eagle Capital'; Indianapolis refers to city = 'Indianapolis'; Indiana refers to state_abbrev = 'IN'
SELECT T2.Date FROM district AS T1 INNER JOIN reviews AS T2 ON T1.district_id = T2.district_id WHERE T2.Product = 'Eagle Capital' AND T1.city = 'Indianapolis' AND T1.state_abbrev = 'IN'
retail_complains
List the product reviewed with 1 star on March 14, 2016 from Newton, Massachusetts.
1 star refers to Stars = 1; on March 14, 2016 refers to Date = '2016-03-14'; Newton refers to city = 'Newton'; Massachusetts refers to state_abbrev = 'MA'
SELECT T2.Product FROM district AS T1 INNER JOIN reviews AS T2 ON T1.district_id = T2.district_id WHERE T1.city = 'Newton' AND T1.state_abbrev = 'MA' AND T2.Date = '2016-03-14' AND T2.Stars = 1
retail_complains
In reviews for the Eagle National Bank product, how many of the 5 star reviews where from Nashville, Tennessee?
5 star refers to Stars = 5; Nashville refers to city = 'Nashville'; Tennessee refers to state_abbrev = 'TN'
SELECT COUNT(T2.Stars) FROM district AS T1 INNER JOIN reviews AS T2 ON T1.district_id = T2.district_id WHERE T1.city = 'Nashville' AND T1.state_abbrev = 'TN' AND T2.Product = 'Eagle National Mortgage' AND T2.Stars = 5
retail_complains
What are the issues of the complains of male clients and products from age 25 and below?
male refers to sex = 'Male'; age 25 and below refers to age < 25
SELECT DISTINCT T2.Issue FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T1.sex = 'Male' AND T1.age < 25
retail_complains
Among the reviews from midwest region, what are the products that received 1 star?
1 star refers to Stars = 1
SELECT DISTINCT T3.Product 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.Region = 'Midwest' AND T3.Stars = 1
retail_complains
What is the division of the review of 5 stars received on December 17, 2017 for the product Eagle National Mortgage?
5 stars refers to Stars = 5; on December 17 2017 refers to Date = '2017-12-17'
SELECT T1.division FROM district AS T1 INNER JOIN reviews AS T2 ON T1.district_id = T2.district_id WHERE T2.Stars = 5 AND T2.Date = '2017-12-17' AND T2.Product = 'Eagle National Mortgage'
retail_complains
In complaints about the credit card product, list the phone number of the oldest client.
oldest refers to max(age)
SELECT T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card' ORDER BY T1.age DESC LIMIT 1