query_id
int64
0
7k
database_id
stringclasses
140 values
table_id
sequencelengths
1
5
query
stringlengths
16
224
answer
stringlengths
18
577
difficulty
stringclasses
4 values
5,700
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What is the name of the dorm with both a TV Lounge and Study Room listed as amenities?
SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
extra
5,701
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
Find the name of dorms which have TV Lounge but no Study Room as amenity.
SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
extra
5,702
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What is the name of each dorm that has a TV Lounge but no study rooms?
SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
extra
5,703
dorm_1
[ "student" ]
Find the last name of students who is either female (sex is F) and living in the city of code BAL or male (sex is M) and in age of below 20.
SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20
extra
5,704
dorm_1
[ "student" ]
What is the last name of every student who is either female or living in a city with the code BAL or male and under 20?
SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20
extra
5,705
dorm_1
[ "dorm" ]
Find the name of the dorm with the largest capacity.
SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
medium
5,706
dorm_1
[ "dorm" ]
What are the names of the dorm with the largest capacity?
SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
medium
5,707
dorm_1
[ "dorm_amenity" ]
List in alphabetic order all different amenities.
SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name
easy
5,708
dorm_1
[ "dorm_amenity" ]
What are the different dorm amenity names in alphabetical order?
SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name
easy
5,709
dorm_1
[ "student" ]
Find the code of city where most of students are living in.
SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
hard
5,710
dorm_1
[ "student" ]
What is the code of the city with the most students?
SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
hard
5,711
dorm_1
[ "student" ]
Find the first and last name of students whose age is younger than the average age.
SELECT fname , lname FROM student WHERE age < (SELECT avg(age) FROM student)
extra
5,712
dorm_1
[ "student" ]
What is the first and last name of all students who are younger than average?
SELECT fname , lname FROM student WHERE age < (SELECT avg(age) FROM student)
extra
5,713
dorm_1
[ "student" ]
List the first and last name of students who are not living in the city with code HKG, and sorted the results by their ages.
SELECT fname , lname FROM student WHERE city_code != 'HKG' ORDER BY age
medium
5,714
dorm_1
[ "student" ]
What are the first and last names of all students who are not living in the city HKG and order the results by age?
SELECT fname , lname FROM student WHERE city_code != 'HKG' ORDER BY age
medium
5,715
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order.
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name
extra
5,716
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What are the amenities in alphabetical order that Anonymous Donor Hall has?
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid = T1.amenid JOIN dorm AS T3 ON T2.dormid = T3.dormid WHERE T3.dorm_name = 'Anonymous Donor Hall' ORDER BY T1.amenity_name
extra
5,717
dorm_1
[ "dorm" ]
Find the number of dorms and total capacity for each gender.
SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender
medium
5,718
dorm_1
[ "dorm" ]
How many dorms are there and what is the total capacity for each gender?
SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender
medium
5,719
dorm_1
[ "student" ]
Find the average and oldest age for students with different sex.
SELECT avg(age) , max(age) , sex FROM student GROUP BY sex
medium
5,720
dorm_1
[ "student" ]
What is the average and oldest age for each gender of student?
SELECT avg(age) , max(age) , sex FROM student GROUP BY sex
medium
5,721
dorm_1
[ "student" ]
Find the number of students in each major.
SELECT count(*) , major FROM student GROUP BY major
medium
5,722
dorm_1
[ "student" ]
How many students are there in each major?
SELECT count(*) , major FROM student GROUP BY major
medium
5,723
dorm_1
[ "student" ]
Find the number and average age of students living in each city.
SELECT count(*) , avg(age) , city_code FROM student GROUP BY city_code
medium
5,724
dorm_1
[ "student" ]
How many students live in each city and what are their average ages?
SELECT count(*) , avg(age) , city_code FROM student GROUP BY city_code
medium
5,725
dorm_1
[ "student" ]
Find the average age and number of male students (with sex M) from each city.
SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code
extra
5,726
dorm_1
[ "student" ]
What is the average age and how many male students are there in each city?
SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code
extra
5,727
dorm_1
[ "student" ]
Find the number of students for the cities where have more than one student.
SELECT count(*) , city_code FROM student GROUP BY city_code HAVING count(*) > 1
medium
5,728
dorm_1
[ "student" ]
How many students are from each city, and which cities have more than one cities?
SELECT count(*) , city_code FROM student GROUP BY city_code HAVING count(*) > 1
medium
5,729
dorm_1
[ "student" ]
Find the first and last name of students who are not in the largest major.
SELECT fname , lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
extra
5,730
dorm_1
[ "student" ]
What is the first and last name of the students who are not in the largest major?
SELECT fname , lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
extra
5,731
dorm_1
[ "student" ]
Find the number of students whose age is older than the average age for each gender.
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
extra
5,732
dorm_1
[ "student" ]
How many students are older than average for each gender?
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
extra
5,733
dorm_1
[ "lives_in", "student", "dorm" ]
Find the average age of students living in each dorm and the name of dorm.
SELECT avg(T1.age) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name
hard
5,734
dorm_1
[ "lives_in", "student", "dorm" ]
What is the average age for each dorm and what are the names of each dorm?
SELECT avg(T1.age) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name
hard
5,735
dorm_1
[ "has_amenity", "dorm" ]
Find the number of amenities for each of the dorms that can accommodate more than 100 students.
SELECT count(*) , T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
hard
5,736
dorm_1
[ "has_amenity", "dorm" ]
For each dorm, how many amenities does it have?
SELECT count(*) , T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
hard
5,737
dorm_1
[ "lives_in", "student", "dorm" ]
Find the number of students who is older than 20 in each dorm.
SELECT count(*) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
extra
5,738
dorm_1
[ "lives_in", "student", "dorm" ]
How many students are older than 20 in each dorm?
SELECT count(*) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
extra
5,739
dorm_1
[ "lives_in", "student", "dorm" ]
Find the first name of students who are living in the Smith Hall.
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'
hard
5,740
dorm_1
[ "lives_in", "student", "dorm" ]
What are the first names of all students in Smith Hall?
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'
hard
5,741
dorm_1
[ "lives_in", "student", "dorm" ]
Find the average age of students who are living in the dorm with the largest capacity.
SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT max(student_capacity) FROM dorm)
extra
5,742
dorm_1
[ "lives_in", "student", "dorm" ]
What is the average age of students who are living in the dorm with the largest capacity?
SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT max(student_capacity) FROM dorm)
extra
5,743
dorm_1
[ "lives_in", "student", "dorm" ]
Find the total number of students living in the male dorm (with gender M).
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M'
hard
5,744
dorm_1
[ "lives_in", "student", "dorm" ]
What are the total number of students who are living in a male dorm?
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M'
hard
5,745
dorm_1
[ "lives_in", "student", "dorm" ]
Find the number of female students (with F sex) living in Smith Hall
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'
hard
5,746
dorm_1
[ "lives_in", "student", "dorm" ]
How many female students live in Smith Hall?
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'
hard
5,747
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
Find the name of amenities Smith Hall dorm have.
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall'
hard
5,748
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What are the names of the amenities that Smith Hall has?
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall'
hard
5,749
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name
extra
5,750
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What amenities does Smith Hall have in alphabetical order?
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name
extra
5,751
dorm_1
[ "has_amenity", "dorm_amenity" ]
Find the name of amenity that is most common in all dorms.
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1
extra
5,752
dorm_1
[ "has_amenity", "dorm_amenity" ]
What is the most common amenity in the dorms?
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1
extra
5,753
dorm_1
[ "student", "lives_in", "has_amenity", "dorm", "dorm_amenity" ]
Find the first name of students who are living in the dorm that has most number of amenities.
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
extra
5,754
dorm_1
[ "student", "lives_in", "has_amenity", "dorm", "dorm_amenity" ]
What are the first names of all students who live in the dorm with the most amenities?
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
extra
5,755
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
Find the name and capacity of the dorm with least number of amenities.
SELECT T1.dorm_name , T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
extra
5,756
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What is the name and capacity of the dorm with the fewest amount of amenities?
SELECT T1.dorm_name , T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
extra
5,757
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
Find the name of dorms that do not have amenity TV Lounge.
SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge'
hard
5,758
dorm_1
[ "has_amenity", "dorm", "dorm_amenity" ]
What are the names of the dorm that does not have a TV Lounge?
SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge'
hard
5,759
dorm_1
[ "lives_in", "student", "has_amenity", "dorm_amenity" ]
Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
SELECT T1.fname , T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
extra
5,760
dorm_1
[ "lives_in", "student", "has_amenity", "dorm_amenity" ]
What are the first and last names of all students who are living in a dorm with a TV Lounge?
SELECT T1.fname , T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
extra
5,761
dorm_1
[ "lives_in", "student", "has_amenity", "dorm_amenity" ]
Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
SELECT T1.fname , T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
extra
5,762
dorm_1
[ "lives_in", "student", "has_amenity", "dorm_amenity" ]
What is the first name and age of every student who lives in a dorm with a TV Lounge?
SELECT T1.fname , T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
extra
5,763
dorm_1
[ "student", "lives_in", "has_amenity", "dorm", "dorm_amenity" ]
Find the name of amenities of the dorm where the student with last name Smith is living in.
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
extra
5,764
dorm_1
[ "student", "lives_in", "has_amenity", "dorm", "dorm_amenity" ]
What are the amenities in the dorm that a student who has the last name of Smith lives in?
SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
extra
5,765
customer_complaints
[ "customers" ]
How many customers are there?
SELECT count(*) FROM customers
easy
5,766
customer_complaints
[ "customers" ]
Count the number of customers.
SELECT count(*) FROM customers
easy
5,767
customer_complaints
[ "customers" ]
Find the emails and phone numbers of all the customers, ordered by email address and phone number.
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
medium
5,768
customer_complaints
[ "customers" ]
What are the emails and phone numbers of all customers, sorted by email address and phone number?
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
medium
5,769
customer_complaints
[ "customers" ]
Which city has the least number of customers whose type code is "Good Credit Rating"?
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
extra
5,770
customer_complaints
[ "customers" ]
Return the city with the customer type code "Good Credit Rating" that had the fewest customers.
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
extra
5,771
customer_complaints
[ "products", "complaints" ]
List the name of all products along with the number of complaints that they have received.
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
medium
5,772
customer_complaints
[ "products", "complaints" ]
What are all the different product names, and how many complains has each received?
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
medium
5,773
customer_complaints
[ "customers", "complaints" ]
Find the emails of customers who has filed a complaints of the product with the most complaints.
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1
extra
5,774
customer_complaints
[ "customers", "complaints" ]
What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints?
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1
extra
5,775
customer_complaints
[ "products", "customers", "complaints" ]
Which products has been complained by the customer who has filed least amount of complaints?
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
extra
5,776
customer_complaints
[ "products", "customers", "complaints" ]
Return the names of products that have had complaints filed by the customer who has filed the fewest complaints.
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
extra
5,777
customer_complaints
[ "customers", "complaints" ]
What is the phone number of the customer who has filed the most recent complaint?
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
hard
5,778
customer_complaints
[ "customers", "complaints" ]
Return the phone number of the customer who filed the complaint that was raised most recently.
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
hard
5,779
customer_complaints
[ "customers", "complaints" ]
Find the email and phone number of the customers who have never filed a complaint before.
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
extra
5,780
customer_complaints
[ "customers", "complaints" ]
What are the emails and phone numbers of custoemrs who have never filed a complaint?
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
extra
5,781
customer_complaints
[ "customers", "staff" ]
Find the phone number of all the customers and staff.
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
hard
5,782
customer_complaints
[ "customers", "staff" ]
What are the phone numbers of all customers and all staff members?
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
hard
5,783
customer_complaints
[ "products" ]
What is the description of the product named "Chocolate"?
SELECT product_description FROM products WHERE product_name = "Chocolate"
easy
5,784
customer_complaints
[ "products" ]
Return the description of the product called "Chocolate".
SELECT product_description FROM products WHERE product_name = "Chocolate"
easy
5,785
customer_complaints
[ "products" ]
Find the name and category of the most expensive product.
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
medium
5,786
customer_complaints
[ "products" ]
What is the name and category code of the product with the highest price?
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
medium
5,787
customer_complaints
[ "products", "complaints" ]
Find the prices of products which has never received a single complaint.
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
hard
5,788
customer_complaints
[ "products", "complaints" ]
What are the prices of products that have never gotten a complaint?
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
hard
5,789
customer_complaints
[ "products" ]
What is the average price of the products for each category?
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
medium
5,790
customer_complaints
[ "products" ]
Return the average price of products that have each category code.
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
medium
5,791
customer_complaints
[ "products", "complaints", "staff" ]
Find the last name of the staff member who processed the complaint of the cheapest product.
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price LIMIT 1
extra
5,792
customer_complaints
[ "products", "complaints", "staff" ]
What is the last name of the staff member in charge of the complaint on the product with the lowest price?
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price LIMIT 1
extra
5,793
customer_complaints
[ "complaints" ]
Which complaint status has more than 3 records on file?
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
easy
5,794
customer_complaints
[ "complaints" ]
Return complaint status codes have more than 3 corresponding complaints?
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
easy
5,795
customer_complaints
[ "staff" ]
Find the last name of the staff whose email address contains "wrau".
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
medium
5,796
customer_complaints
[ "staff" ]
What are the last names of staff with email addressed containing the substring "wrau"?
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
medium
5,797
customer_complaints
[ "customers" ]
How many customers are there in the customer type with the most customers?
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
hard
5,798
customer_complaints
[ "customers" ]
Count the number of customers that have the customer type that is most common.
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
hard
5,799
customer_complaints
[ "complaints", "staff" ]
What is the last name of the staff who has handled the first ever complaint?
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id ORDER BY t2.date_complaint_raised LIMIT 1
hard