schema
stringlengths 144
5.45k
| question
stringlengths 16
224
| query
stringlengths 18
577
| hardness
stringclasses 5
values |
---|---|---|---|
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | Find the numbers of different majors and cities. | SELECT count(DISTINCT major) , count(DISTINCT city_code) FROM student | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | How many different majors are there and how many different city codes are there for each student? | SELECT count(DISTINCT major) , count(DISTINCT city_code) FROM student | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | Find the name of dorms which have both TV Lounge and Study Room 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | Find the name of the dorm with the largest capacity. | SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1 | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | What are the names of the dorm with the largest capacity? | SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1 | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | List in alphabetic order all different amenities. | SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name | easy |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | What are the different dorm amenity names in alphabetical order? | SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name | easy |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | Find the number of dorms and total capacity for each gender. | SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | Find the average and oldest age for students with different sex. | SELECT avg(age) , max(age) , sex FROM student GROUP BY sex | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | What is the average and oldest age for each gender of student? | SELECT avg(age) , max(age) , sex FROM student GROUP BY sex | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | Find the number of students in each major. | SELECT count(*) , major FROM student GROUP BY major | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | How many students are there in each major? | SELECT count(*) , major FROM student GROUP BY major | medium |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Student (StuID number, LName text, Fname text, Age number, Sex text, Major number, Advisor number, city_code text); CREATE TABLE Dorm (dormid number, dorm_name text, student_capacity number, gender text); CREATE TABLE Dorm_amenity (amenid number, amenity_name text); CREATE TABLE Has_amenity (dormid number, amenid number); CREATE TABLE Lives_in (stuid number, dormid number, room_number number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | How many customers are there? | SELECT count(*) FROM customers | easy |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | Count the number of customers. | SELECT count(*) FROM customers | easy |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | Find the phone number of all the customers and staff. | SELECT phone_number FROM customers UNION SELECT phone_number FROM staff | hard |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | What are the phone numbers of all customers and all staff members? | SELECT phone_number FROM customers UNION SELECT phone_number FROM staff | hard |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | What is the description of the product named "Chocolate"? | SELECT product_description FROM products WHERE product_name = "Chocolate" | easy |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | Return the description of the product called "Chocolate". | SELECT product_description FROM products WHERE product_name = "Chocolate" | easy |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | Find the last name of the staff whose email address contains "wrau". | SELECT last_name FROM staff WHERE email_address LIKE "%wrau%" | medium |
CREATE TABLE Staff (staff_id number, gender text, first_name text, last_name text, email_address text, phone_number text); CREATE TABLE Customers (customer_id number, customer_type_code text, address_line_1 text, address_line_2 text, town_city text, state text, email_address text, phone_number text); CREATE TABLE Products (product_id number, parent_product_id number, product_category_code text, date_product_first_available time, date_product_discontinued time, product_name text, product_description text, product_price number); CREATE TABLE Complaints (complaint_id number, product_id number, customer_id number, complaint_outcome_code text, complaint_status_code text, complaint_type_code text, date_complaint_raised time, date_complaint_closed time, staff_id number); | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.