Search is not available for this dataset
db_id
stringlengths
3
31
query
stringlengths
20
523
question
stringlengths
3
224
schema
stringlengths
589
322M
query_res
stringlengths
0
363k
dorm_1
SELECT avg(age) , max(age) , sex FROM student GROUP BY sex
What is the average and oldest age for each gender of student?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(19.7, 26, 'F') (19.5, 27, 'M')
dorm_1
SELECT count(*) , major FROM student GROUP BY major
Find the number of students in each major.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(2, 50) (1, 100) (6, 520) (2, 540) (5, 550) (18, 600)
dorm_1
SELECT count(*) , major FROM student GROUP BY major
How many students are there in each major?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(2, 50) (1, 100) (6, 520) (2, 540) (5, 550) (18, 600)
dorm_1
SELECT count(*) , avg(age) , city_code FROM student GROUP BY city_code
Find the number and average age of students living in each city.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1, 20.0, 'ATL') (4, 18.5, 'BAL') (1, 18.0, 'BOS') (1, 20.0, 'CHI') (1, 18.0, 'DAL') (1, 17.0, 'DET') (3, 18.0, 'HKG') (1, 17.0, 'HOU') (1, 27.0, 'LON') (1, 18.0, 'LOS') (1, 18.0, 'NAR') (3, 20.333333333333332, 'NYC') (1, 17.0, 'PEK') (3, 19.666666666666668, 'PHL') (4, 19.0, 'PIT') (1, 20.0, 'ROC') (1, 21.0, 'SFO') (3,...
dorm_1
SELECT count(*) , avg(age) , city_code FROM student GROUP BY city_code
How many students live in each city and what are their average ages?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1, 20.0, 'ATL') (4, 18.5, 'BAL') (1, 18.0, 'BOS') (1, 20.0, 'CHI') (1, 18.0, 'DAL') (1, 17.0, 'DET') (3, 18.0, 'HKG') (1, 17.0, 'HOU') (1, 27.0, 'LON') (1, 18.0, 'LOS') (1, 18.0, 'NAR') (3, 20.333333333333332, 'NYC') (1, 17.0, 'PEK') (3, 19.666666666666668, 'PHL') (4, 19.0, 'PIT') (1, 20.0, 'ROC') (1, 21.0, 'SFO') (3,...
dorm_1
SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code
Find the average age and number of male students (with sex M) from each city.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1, 20.0, 'ATL') (1, 18.0, 'BAL') (1, 18.0, 'BOS') (1, 20.0, 'CHI') (1, 18.0, 'DAL') (1, 17.0, 'DET') (1, 19.0, 'HKG') (1, 17.0, 'HOU') (1, 27.0, 'LON') (1, 18.0, 'LOS') (1, 18.0, 'NAR') (3, 20.333333333333332, 'NYC') (1, 17.0, 'PEK') (2, 19.5, 'PHL') (3, 19.333333333333332, 'PIT') (1, 20.0, 'ROC') (1, 18.0, 'WAS') (2,...
dorm_1
SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code
What is the average age and how many male students are there in each city?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1, 20.0, 'ATL') (1, 18.0, 'BAL') (1, 18.0, 'BOS') (1, 20.0, 'CHI') (1, 18.0, 'DAL') (1, 17.0, 'DET') (1, 19.0, 'HKG') (1, 17.0, 'HOU') (1, 27.0, 'LON') (1, 18.0, 'LOS') (1, 18.0, 'NAR') (3, 20.333333333333332, 'NYC') (1, 17.0, 'PEK') (2, 19.5, 'PHL') (3, 19.333333333333332, 'PIT') (1, 20.0, 'ROC') (1, 18.0, 'WAS') (2,...
dorm_1
SELECT count(*) , city_code FROM student GROUP BY city_code HAVING count(*) > 1
Find the number of students for the cities where have more than one student.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(4, 'BAL') (3, 'HKG') (3, 'NYC') (3, 'PHL') (4, 'PIT') (3, 'WAS') (2, 'YYZ')
dorm_1
SELECT count(*) , city_code FROM student GROUP BY city_code HAVING count(*) > 1
How many students are from each city, and which cities have more than one cities?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(4, 'BAL') (3, 'HKG') (3, 'NYC') (3, 'PHL') (4, 'PIT') (3, 'WAS') (2, 'YYZ')
dorm_1
SELECT fname , lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
Find the first and last name of students who are not in the largest major.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Ian', 'Thornton') ('George', 'Andreou') ('Michael', 'Woods') ('David', 'Shieber') ('Stacy', 'Prater') ('Mark', 'Goldman') ('Eric', 'Pang') ('Paul', 'Brody') ('Eric', 'Rugh') ('Jun', 'Han') ('Lisa', 'Cheng') ('Sarah', 'Smith') ('Eric', 'Brown') ('William', 'Simms') ('Eric', 'Epp') ('Sarah', 'Schmidt')
dorm_1
SELECT fname , lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
What is the first and last name of the students who are not in the largest major?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Ian', 'Thornton') ('George', 'Andreou') ('Michael', 'Woods') ('David', 'Shieber') ('Stacy', 'Prater') ('Mark', 'Goldman') ('Eric', 'Pang') ('Paul', 'Brody') ('Eric', 'Rugh') ('Jun', 'Han') ('Lisa', 'Cheng') ('Sarah', 'Smith') ('Eric', 'Brown') ('William', 'Simms') ('Eric', 'Epp') ('Sarah', 'Schmidt')
dorm_1
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
Find the number of students whose age is older than the average age for each gender.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(5, 'F') (10, 'M')
dorm_1
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
How many students are older than average for each gender?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(5, 'F') (10, 'M')
dorm_1
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
Find the average age of students living in each dorm and the name of dorm.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(19.666666666666668, 'Anonymous Donor Hall') (20.0, 'Bud Jones Hall') (19.6, 'Dorm-plex 2000') (19.77777777777778, 'Fawlty Towers') (18.0, 'Grad Student Asylum') (20.166666666666668, 'Smith Hall') (18.0, 'University Hovels')
dorm_1
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
What is the average age for each dorm and what are the names of each dorm?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(19.666666666666668, 'Anonymous Donor Hall') (20.0, 'Bud Jones Hall') (19.6, 'Dorm-plex 2000') (19.77777777777778, 'Fawlty Towers') (18.0, 'Grad Student Asylum') (20.166666666666668, 'Smith Hall') (18.0, 'University Hovels')
dorm_1
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
Find the number of amenities for each of the dorms that can accommodate more than 100 students.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(3, 104) (8, 109) (5, 110) (6, 140) (12, 160)
dorm_1
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
For each dorm, how many amenities does it have?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(3, 104) (8, 109) (5, 110) (6, 140) (12, 160)
dorm_1
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
Find the number of students who is older than 20 in each dorm.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1, 'Anonymous Donor Hall') (2, 'Dorm-plex 2000') (2, 'Fawlty Towers') (2, 'Smith Hall')
dorm_1
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
How many students are older than 20 in each dorm?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1, 'Anonymous Donor Hall') (2, 'Dorm-plex 2000') (2, 'Fawlty Towers') (2, 'Smith Hall')
dorm_1
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'
Find the first name of students who are living in the Smith Hall.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Tracy',) ('Shiela',) ('Michael',) ('Stacy',) ('Sarah',) ('Sarah',)
dorm_1
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'
What are the first names of all students in Smith Hall?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Tracy',) ('Shiela',) ('Michael',) ('Stacy',) ('Sarah',) ('Sarah',)
dorm_1
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)
Find the average age of students who are living in the dorm with the largest capacity.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(19.6,)
dorm_1
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)
What is the average age of students who are living in the dorm with the largest capacity?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(19.6,)
dorm_1
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'
Find the total number of students living in the male dorm (with gender M).
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1,)
dorm_1
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'
What are the total number of students who are living in a male dorm?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(1,)
dorm_1
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'
Find the number of female students (with F sex) living in Smith Hall
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(5,)
dorm_1
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'
How many female students live in Smith Hall?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
(5,)
dorm_1
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'
Find the name of amenities Smith Hall dorm have.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Study Room',) ('Carpeted Rooms',) ('4 Walls',) ('Heat',) ('Roof',)
dorm_1
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'
What are the names of the amenities that Smith Hall has?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Study Room',) ('Carpeted Rooms',) ('4 Walls',) ('Heat',) ('Roof',)
dorm_1
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
Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('4 Walls',) ('Carpeted Rooms',) ('Heat',) ('Roof',) ('Study Room',)
dorm_1
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
What amenities does Smith Hall have in alphabetical order?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('4 Walls',) ('Carpeted Rooms',) ('Heat',) ('Roof',) ('Study Room',)
dorm_1
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
Find the name of amenity that is most common in all dorms.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Roof',)
dorm_1
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
What is the most common amenity in the dorms?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Roof',)
dorm_1
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)
Find the first name of students who are living in the dorm that has most number of amenities.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Linda',) ('Tracy',) ('Shiela',) ('Dinesh',) ('Paul',) ('Lisa',) ('Jandy',) ('Eric',) ('Derek',) ('David',) ('Steven',) ('Charles',) ('Susan',) ('Mark',) ('Bruce',) ('Michael',) ('Ian',) ('George',) ('Michael',) ('David',) ('Stacy',) ('Mark',) ('Paul',) ('Eric',) ('Jun',) ('Lisa',) ('Sarah',) ('Eric',) ('William',) ('...
dorm_1
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)
What are the first names of all students who live in the dorm with the most amenities?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Linda',) ('Tracy',) ('Shiela',) ('Dinesh',) ('Paul',) ('Lisa',) ('Jandy',) ('Eric',) ('Derek',) ('David',) ('Steven',) ('Charles',) ('Susan',) ('Mark',) ('Bruce',) ('Michael',) ('Ian',) ('George',) ('Michael',) ('David',) ('Stacy',) ('Mark',) ('Paul',) ('Eric',) ('Jun',) ('Lisa',) ('Sarah',) ('Eric',) ('William',) ('...
dorm_1
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
Find the name and capacity of the dorm with least number of amenities.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('University Hovels', 40)
dorm_1
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
What is the name and capacity of the dorm with the fewest amount of amenities?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('University Hovels', 40)
dorm_1
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'
Find the name of dorms that do not have amenity TV Lounge.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Bud Jones Hall',) ('Grad Student Asylum',) ('Smith Hall',) ('University Hovels',)
dorm_1
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'
What are the names of the dorm that does not have a TV Lounge?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Bud Jones Hall',) ('Grad Student Asylum',) ('Smith Hall',) ('University Hovels',)
dorm_1
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')
Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Linda', 'Smith') ('Dinesh', 'Kumar') ('Paul', 'Gompers') ('Lisa', 'Apap') ('Jandy', 'Nelson') ('Eric', 'Tai') ('Derek', 'Lee') ('David', 'Adams') ('Steven', 'Davis') ('Susan', 'Lee') ('Mark', 'Schwartz') ('Bruce', 'Wilson') ('Michael', 'Leighton') ('Ian', 'Thornton') ('George', 'Andreou') ('David', 'Shieber') ('Mark'...
dorm_1
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')
What are the first and last names of all students who are living in a dorm with a TV Lounge?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Linda', 'Smith') ('Dinesh', 'Kumar') ('Paul', 'Gompers') ('Lisa', 'Apap') ('Jandy', 'Nelson') ('Eric', 'Tai') ('Derek', 'Lee') ('David', 'Adams') ('Steven', 'Davis') ('Susan', 'Lee') ('Mark', 'Schwartz') ('Bruce', 'Wilson') ('Michael', 'Leighton') ('Ian', 'Thornton') ('George', 'Andreou') ('David', 'Shieber') ('Mark'...
dorm_1
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')
Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Tracy', 19) ('Shiela', 21) ('Charles', 18) ('Michael', 17) ('Stacy', 18) ('Eric', 20) ('Sarah', 20) ('William', 18) ('Sarah', 26)
dorm_1
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')
What is the first name and age of every student who lives in a dorm with a TV Lounge?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('Tracy', 19) ('Shiela', 21) ('Charles', 18) ('Michael', 17) ('Stacy', 18) ('Eric', 20) ('Sarah', 20) ('William', 18) ('Sarah', 26)
dorm_1
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'
Find the name of amenities of the dorm where the student with last name Smith is living in.
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('TV Lounge',) ('Study Room',) ('Carpeted Rooms',) ('4 Walls',) ('Heat',) ('Roof',) ('Ethernet Ports',) ('Air Conditioning',) ('Study Room',) ('Carpeted Rooms',) ('4 Walls',) ('Heat',) ('Roof',)
dorm_1
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'
What are the amenities in the dorm that a student who has the last name of Smith lives in?
create table Student ( StuID INTEGER PRIMARY KEY, LName VARCHAR(12), Fname VARCHAR(12), Age INTEGER, Sex VARCHAR(1), Major INTEGER, Advisor INTEGER, city_code VARCHAR(3) ); create table Dorm ( dormi...
('TV Lounge',) ('Study Room',) ('Carpeted Rooms',) ('4 Walls',) ('Heat',) ('Roof',) ('Ethernet Ports',) ('Air Conditioning',) ('Study Room',) ('Carpeted Rooms',) ('4 Walls',) ('Heat',) ('Roof',)
customer_complaints
SELECT count(*) FROM customers
How many customers are there?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(8,)
customer_complaints
SELECT count(*) FROM customers
Count the number of customers.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(8,)
customer_complaints
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
Find the emails and phone numbers of all the customers, ordered by email address and phone number.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('cayla.satterfield@example.net', '470-803-0244') ('hsteuber@example.org', '06963347450') ('lavonne.frami@example.com', '+38(3)9011433816') ('paige.hyatt@example.com', '1-369-302-7623x576') ('rzulauf@example.org', '578.019.7943x328') ('ubeier@example.org', '044-468-4549') ('vbogisich@example.org', '548.373.3603x59134')...
customer_complaints
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
What are the emails and phone numbers of all customers, sorted by email address and phone number?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('cayla.satterfield@example.net', '470-803-0244') ('hsteuber@example.org', '06963347450') ('lavonne.frami@example.com', '+38(3)9011433816') ('paige.hyatt@example.com', '1-369-302-7623x576') ('rzulauf@example.org', '578.019.7943x328') ('ubeier@example.org', '044-468-4549') ('vbogisich@example.org', '548.373.3603x59134')...
customer_complaints
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
Which city has the least number of customers whose type code is "Good Credit Rating"?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Hansenbury',)
customer_complaints
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
Return the city with the customer type code "Good Credit Rating" that had the fewest customers.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Hansenbury',)
customer_complaints
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
List the name of all products along with the number of complaints that they have received.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Chocolate', 6) ('Keyboard', 1) ('Mouse', 1) ('The Great Gatsby', 4)
customer_complaints
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
What are all the different product names, and how many complains has each received?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Chocolate', 6) ('Keyboard', 1) ('Mouse', 1) ('The Great Gatsby', 4)
customer_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
Find the emails of customers who has filed a complaints of the product with the most complaints.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('hsteuber@example.org',)
customer_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
What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('hsteuber@example.org',)
customer_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
Which products has been complained by the customer who has filed least amount of complaints?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Chocolate',)
customer_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
Return the names of products that have had complaints filed by the customer who has filed the fewest complaints.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Chocolate',)
customer_complaints
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
What is the phone number of the customer who has filed the most recent complaint?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('+38(3)9011433816',)
customer_complaints
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
Return the phone number of the customer who filed the complaint that was raised most recently.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('+38(3)9011433816',)
customer_complaints
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
Find the email and phone number of the customers who have never filed a complaint before.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('paige.hyatt@example.com', '1-369-302-7623x576')
customer_complaints
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
What are the emails and phone numbers of custoemrs who have never filed a complaint?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('paige.hyatt@example.com', '1-369-302-7623x576')
customer_complaints
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
Find the phone number of all the customers and staff.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('(379)551-0838x146',) ('(383)553-1035x20399',) ('+38(3)9011433816',) ('044-468-4549',) ('06963347450',) ('1-132-839-9409x288',) ('1-369-302-7623x576',) ('142-311-6503x206',) ('155-811-6153',) ('345-656-5571',) ('470-803-0244',) ('548.373.3603x59134',) ('578.019.7943x328',) ('751-262-8424x575',) ('997.698.4779x882',)
customer_complaints
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What are the phone numbers of all customers and all staff members?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('(379)551-0838x146',) ('(383)553-1035x20399',) ('+38(3)9011433816',) ('044-468-4549',) ('06963347450',) ('1-132-839-9409x288',) ('1-369-302-7623x576',) ('142-311-6503x206',) ('155-811-6153',) ('345-656-5571',) ('470-803-0244',) ('548.373.3603x59134',) ('578.019.7943x328',) ('751-262-8424x575',) ('997.698.4779x882',)
customer_complaints
SELECT product_description FROM products WHERE product_name = "Chocolate"
What is the description of the product named "Chocolate"?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Handmade chocolate',)
customer_complaints
SELECT product_description FROM products WHERE product_name = "Chocolate"
Return the description of the product called "Chocolate".
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Handmade chocolate',)
customer_complaints
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
Find the name and category of the most expensive product.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Keyboard', 'Hardware')
customer_complaints
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
What is the name and category code of the product with the highest price?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Keyboard', 'Hardware')
customer_complaints
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
Find the prices of products which has never received a single complaint.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
customer_complaints
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
What are the prices of products that have never gotten a complaint?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
customer_complaints
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
What is the average price of the products for each category?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(35.0, 'Book') (2.88, 'Food') (66.67, 'Hardware')
customer_complaints
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
Return the average price of products that have each category code.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(35.0, 'Book') (2.88, 'Food') (66.67, 'Hardware')
customer_complaints
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
Find the last name of the staff member who processed the complaint of the cheapest product.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Boehm',)
customer_complaints
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
What is the last name of the staff member in charge of the complaint on the product with the lowest price?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Boehm',)
customer_complaints
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Which complaint status has more than 3 records on file?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('New',) ('Open',)
customer_complaints
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Return complaint status codes have more than 3 corresponding complaints?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('New',) ('Open',)
customer_complaints
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
Find the last name of the staff whose email address contains "wrau".
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Erdman',)
customer_complaints
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
What are the last names of staff with email addressed containing the substring "wrau"?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Erdman',)
customer_complaints
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
How many customers are there in the customer type with the most customers?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(6,)
customer_complaints
SELECT count(*) FROM customers GROUP BY customer_type_code ORDER BY count(*) DESC LIMIT 1
Count the number of customers that have the customer type that is most common.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(6,)
customer_complaints
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
What is the last name of the staff who has handled the first ever complaint?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Lynch',)
customer_complaints
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
Return the last name of the staff member who handled the complaint with the earliest date raised.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Lynch',)
customer_complaints
SELECT count(DISTINCT complaint_type_code) FROM complaints
How many distinct complaint type codes are there in the database?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(2,)
customer_complaints
SELECT count(DISTINCT complaint_type_code) FROM complaints
Count the number of different complaint type codes.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
(2,)
customer_complaints
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"
Find the address line 1 and 2 of the customer with email "vbogisich@example.org".
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('72144 Katlynn Flat Suite 512', 'Suite 959')
customer_complaints
SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org"
What are lines 1 and 2 of the addressed of the customer with the email "vbogisich@example.org"?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('72144 Katlynn Flat Suite 512', 'Suite 959')
customer_complaints
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
Find the number of complaints with Product Failure type for each complaint status.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Closed', 1) ('Open', 1)
customer_complaints
SELECT complaint_status_code , count(*) FROM complaints WHERE complaint_type_code = "Product Failure" GROUP BY complaint_status_code
Of complaints with the type code "Product Failure", how many had each different status code?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Closed', 1) ('Open', 1)
customer_complaints
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
What is first names of the top 5 staff who have handled the greatest number of complaints?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Dagmar',) ('Bradly',) ('Austin',) ('Lucie',) ('Mikel',)
customer_complaints
SELECT t1.first_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id GROUP BY t2.staff_id ORDER BY count(*) LIMIT 5
Return the first names of the 5 staff members who have handled the most complaints.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Dagmar',) ('Bradly',) ('Austin',) ('Lucie',) ('Mikel',)
customer_complaints
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
Which state has the most customers?
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Colorado',)
customer_complaints
SELECT state FROM customers GROUP BY state ORDER BY count(*) LIMIT 1
Give the state that has the most customers.
PRAGMA foreign_keys = ON; CREATE TABLE `Staff` ( `staff_id` INTEGER PRIMARY KEY, `gender` VARCHAR(1), `first_name` VARCHAR(80), `last_name` VARCHAR(80), `email_address` VARCHAR(255), `phone_number` VARCHAR(80) ); INSERT INTO Staff (`staff_id`, `gender`, `first_name`, `last_name`, `email_address`, `phone_number`) VALU...
('Colorado',)
workshop_paper
SELECT count(*) FROM submission
How many submissions are there?
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
(10,)
workshop_paper
SELECT count(*) FROM submission
Count the number of submissions.
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
(10,)
workshop_paper
SELECT Author FROM submission ORDER BY Scores ASC
List the authors of submissions in ascending order of scores.
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
('Steve Niehaus',) ('Sherman Smith',) ('Sammy Green',) ('Steve Raible',) ('Jeff Lloyd',) ('Randy Johnson',) ('Andy Bolton',) ('Rick Engles',) ('Don Bitterlich',) ('Steve Myer',)
workshop_paper
SELECT Author FROM submission ORDER BY Scores ASC
Find the author for each submission and list them in ascending order of submission score.
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
('Steve Niehaus',) ('Sherman Smith',) ('Sammy Green',) ('Steve Raible',) ('Jeff Lloyd',) ('Randy Johnson',) ('Andy Bolton',) ('Rick Engles',) ('Don Bitterlich',) ('Steve Myer',)
workshop_paper
SELECT Author , College FROM submission
What are the authors of submissions and their colleges?
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
('Steve Niehaus', 'Notre Dame') ('Sammy Green', 'Florida') ('Sherman Smith', 'Miami (OH)') ('Steve Raible', 'Georgia Tech') ('Jeff Lloyd', 'West Texas State') ('Rick Engles', 'Tulsa') ('Don Bitterlich', 'Temple') ('Steve Myer', 'New Mexico') ('Randy Johnson', 'Georgia') ('Andy Bolton', 'Fisk')
workshop_paper
SELECT Author , College FROM submission
For each submission, show the author and their affiliated college.
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
('Steve Niehaus', 'Notre Dame') ('Sammy Green', 'Florida') ('Sherman Smith', 'Miami (OH)') ('Steve Raible', 'Georgia Tech') ('Jeff Lloyd', 'West Texas State') ('Rick Engles', 'Tulsa') ('Don Bitterlich', 'Temple') ('Steve Myer', 'New Mexico') ('Randy Johnson', 'Georgia') ('Andy Bolton', 'Fisk')
workshop_paper
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
Show the names of authors from college "Florida" or "Temple"
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
('Sammy Green',) ('Don Bitterlich',)
workshop_paper
SELECT Author FROM submission WHERE College = "Florida" OR College = "Temple"
Which authors with submissions are from college "Florida" or "Temple"?
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
('Sammy Green',) ('Don Bitterlich',)
workshop_paper
SELECT avg(Scores) FROM submission
What is the average score of submissions?
PRAGMA foreign_keys = ON; CREATE TABLE "workshop" ( "Workshop_ID" int, "Date" text, "Venue" text, "Name" text, PRIMARY KEY ("Workshop_ID") ); CREATE TABLE "submission" ( "Submission_ID" int, "Scores" real, "Author" text, "College" text, PRIMARY KEY ("Submission_ID") ); INSERT INTO "workshop" VALUES (1,"August 18, ...
(82.9,)