Question: What are the manager's first name, last name and id who won the most manager award?

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, player_id VARCHAR); CREATE TABLE manager_award (player_id VARCHAR)

SELECT T1.name_first, T1.name_last, T2.player_id FROM player AS T1 JOIN manager_award AS T2 ON T1.player_id = T2.player_id GROUP BY T2.player_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many parks are there in the state of NY?

Context: CREATE TABLE park (state VARCHAR)

SELECT COUNT(*) FROM park WHERE state = 'NY'


Question: Which 3 players won the most player awards? List their full name and id.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, player_id VARCHAR); CREATE TABLE player_award (player_id VARCHAR)

SELECT T1.name_first, T1.name_last, T1.player_id FROM player AS T1 JOIN player_award AS T2 ON T1.player_id = T2.player_id GROUP BY T1.player_id ORDER BY COUNT(*) DESC LIMIT 3


Question: List three countries which are the origins of the least players.

Context: CREATE TABLE player (birth_country VARCHAR)

SELECT birth_country FROM player GROUP BY birth_country ORDER BY COUNT(*) LIMIT 3


Question: Find all the players' first name and last name who have empty death record.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, death_year VARCHAR)

SELECT name_first, name_last FROM player WHERE death_year = ''


Question: How many players born in USA are right-handed batters? That is, have the batter value 'R'.

Context: CREATE TABLE player (birth_country VARCHAR, bats VARCHAR)

SELECT COUNT(*) FROM player WHERE birth_country = 'USA' AND bats = 'R'


Question: What is the average height of the players from the college named 'Yale University'?

Context: CREATE TABLE player_college (player_id VARCHAR, college_id VARCHAR); CREATE TABLE player (height INTEGER, player_id VARCHAR); CREATE TABLE college (college_id VARCHAR, name_full VARCHAR)

SELECT AVG(T1.height) FROM player AS T1 JOIN player_college AS T2 ON T1.player_id = T2.player_id JOIN college AS T3 ON T3.college_id = T2.college_id WHERE T3.name_full = 'Yale University'


Question: What is the highest salary among each team? List the team name, id and maximum salary.

Context: CREATE TABLE salary (salary INTEGER, team_id VARCHAR); CREATE TABLE team (name VARCHAR, team_id VARCHAR)

SELECT T1.name, T1.team_id, MAX(T2.salary) FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id


Question: What are the name and id of the team offering the lowest average salary?

Context: CREATE TABLE team (name VARCHAR, team_id VARCHAR); CREATE TABLE salary (team_id VARCHAR, salary INTEGER)

SELECT T1.name, T1.team_id FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id ORDER BY AVG(T2.salary) LIMIT 1


Question: Find the players' first name and last name who won award both in 1960 and in 1961.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR); CREATE TABLE player_award (year VARCHAR)

SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1960 INTERSECT SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1961


Question: List players' first name and last name who have weight greater than 220 or height shorter than 75.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, weight VARCHAR, height VARCHAR)

SELECT name_first, name_last FROM player WHERE weight > 220 OR height < 75


Question: List the maximum scores of the team Boston Red Stockings when the team won in postseason?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE postseason (wins INTEGER, team_id_winner VARCHAR)

SELECT MAX(T1.wins) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings'


Question: How many times did Boston Red Stockings lose in 2009 postseason?

Context: CREATE TABLE postseason (team_id_loser VARCHAR, year VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

SELECT COUNT(*) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2009


Question: What are the name and id of the team with the most victories in 2008 postseason?

Context: CREATE TABLE postseason (team_id_winner VARCHAR, year VARCHAR); CREATE TABLE team (name VARCHAR, team_id_br VARCHAR)

SELECT T2.name, T1.team_id_winner FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T1.year = 2008 GROUP BY T1.team_id_winner ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the number of wins the team Boston Red Stockings got in the postseasons each year in history?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE postseason (year VARCHAR, team_id_winner VARCHAR)

SELECT COUNT(*), T1.year FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' GROUP BY T1.year


Question: What is the total number of postseason games that team Boston Red Stockings participated in?

Context: CREATE TABLE postseason (team_id_winner VARCHAR, team_id_loser VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

SELECT COUNT(*) FROM (SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' UNION SELECT * FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_loser = T2.team_id_br WHERE T2.name = 'Boston Red Stockings')


Question: How many games in 1885 postseason resulted in ties (that is, the value of "ties" is '1')?

Context: CREATE TABLE postseason (YEAR VARCHAR, ties VARCHAR)

SELECT COUNT(*) FROM postseason WHERE YEAR = 1885 AND ties = 1


Question: What is the total salary paid by team Boston Red Stockings in 2010?

Context: CREATE TABLE salary (salary INTEGER, team_id VARCHAR, year VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

SELECT SUM(T1.salary) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2010


Question: How many players were in the team Boston Red Stockings in 2000?

Context: CREATE TABLE salary (team_id VARCHAR, year VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR)

SELECT COUNT(*) FROM salary AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year = 2000


Question: List the 3 highest salaries of the players in 2001?

Context: CREATE TABLE salary (salary VARCHAR, YEAR VARCHAR)

SELECT salary FROM salary WHERE YEAR = 2001 ORDER BY salary DESC LIMIT 3


Question: What were all the salary values of players in 2010 and 2001?

SELECT salary FROM salary WHERE YEAR = 2010 UNION SELECT salary FROM salary WHERE YEAR = 2001


Question: In which year did the least people enter hall of fame?

Context: CREATE TABLE hall_of_fame (yearid VARCHAR)

SELECT yearid FROM hall_of_fame GROUP BY yearid ORDER BY COUNT(*) LIMIT 1


Question: How many parks are there in Atlanta city?

Context: CREATE TABLE park (city VARCHAR)

SELECT COUNT(*) FROM park WHERE city = 'Atlanta'


Question: How many games were played in park "Columbia Park" in 1907?

Context: CREATE TABLE park (park_id VARCHAR, park_name VARCHAR); CREATE TABLE home_game (park_id VARCHAR, year VARCHAR)

SELECT COUNT(*) FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 1907 AND T2.park_name = 'Columbia Park'


Question: How many games were played in city Atlanta in 2000?

Context: CREATE TABLE park (park_id VARCHAR, city VARCHAR); CREATE TABLE home_game (park_id VARCHAR, year VARCHAR)

SELECT COUNT(*) FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 2000 AND T2.city = 'Atlanta'


Question: What is the total home game attendance of team Boston Red Stockings from 2000 to 2010?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE home_game (attendance INTEGER, team_id VARCHAR, year VARCHAR)

SELECT SUM(T1.attendance) FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year BETWEEN 2000 AND 2010


Question: How much did the the player with first name Len and last name Barker earn between 1985 to 1990 in total?

Context: CREATE TABLE salary (salary INTEGER, player_id VARCHAR, year VARCHAR); CREATE TABLE player (player_id VARCHAR, name_first VARCHAR, name_last VARCHAR)

SELECT SUM(T1.salary) FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id WHERE T2.name_first = 'Len' AND T2.name_last = 'Barker' AND T1.year BETWEEN 1985 AND 1990


Question: List players' first name and last name who received salary from team Washington Nationals in both 2005 and 2007.

Context: CREATE TABLE player (name_first VARCHAR, name_last VARCHAR, player_id VARCHAR); CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE salary (player_id VARCHAR, team_id VARCHAR, year VARCHAR)

SELECT T2.name_first, T2.name_last FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id JOIN team AS T3 ON T3.team_id_br = T1.team_id WHERE T1.year = 2005 AND T3.name = 'Washington Nationals' INTERSECT SELECT T2.name_first, T2.name_last FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id JOIN team AS T3 ON T3.team_id_br = T1.team_id WHERE T1.year = 2007 AND T3.name = 'Washington Nationals'


Question: How many home games did the team Boston Red Stockings play from 1990 to 2000 in total?

Context: CREATE TABLE team (team_id_br VARCHAR, name VARCHAR); CREATE TABLE home_game (games INTEGER, team_id VARCHAR, year VARCHAR)

SELECT SUM(T1.games) FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year BETWEEN 1990 AND 2000


Question: Which team had the least number of attendances in home games in 1980?

Context: CREATE TABLE home_game (team_id VARCHAR, year VARCHAR, attendance VARCHAR); CREATE TABLE team (name VARCHAR, team_id_br VARCHAR)

SELECT T2.name FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T1.year = 1980 ORDER BY T1.attendance LIMIT 1


Question: List the names of states that have more than 2 parks.

Context: CREATE TABLE park (state VARCHAR)

SELECT state FROM park GROUP BY state HAVING COUNT(*) > 2


Question: How many team franchises are active, with active value 'Y'?

Context: CREATE TABLE team_franchise (active VARCHAR)

SELECT COUNT(*) FROM team_franchise WHERE active = 'Y'


Question: Which cities have 2 to 4 parks?

Context: CREATE TABLE park (city VARCHAR)

SELECT city FROM park GROUP BY city HAVING COUNT(*) BETWEEN 2 AND 4


Question: Which park had most attendances in 2008?

Context: CREATE TABLE park (park_name VARCHAR, park_id VARCHAR); CREATE TABLE home_game (park_id VARCHAR, year VARCHAR, attendance VARCHAR)

SELECT T2.park_name FROM home_game AS T1 JOIN park AS T2 ON T1.park_id = T2.park_id WHERE T1.year = 2008 ORDER BY T1.attendance DESC LIMIT 1


Question: How many camera lenses have a focal length longer than 15 mm?

Context: CREATE TABLE camera_lens (focal_length_mm INTEGER)

SELECT COUNT(*) FROM camera_lens WHERE focal_length_mm > 15


Question: Find the brand and name for each camera lens, and sort in descending order of maximum aperture.

Context: CREATE TABLE camera_lens (brand VARCHAR, name VARCHAR, max_aperture VARCHAR)

SELECT brand, name FROM camera_lens ORDER BY max_aperture DESC


Question: List the id, color scheme, and name for all the photos.

Context: CREATE TABLE photos (id VARCHAR, color VARCHAR, name VARCHAR)


Question: What are the maximum and average height of the mountains?

Context: CREATE TABLE mountain (height INTEGER)

SELECT MAX(height), AVG(height) FROM mountain


Question: What are the average prominence of the mountains in country 'Morocco'?

Context: CREATE TABLE mountain (prominence INTEGER, country VARCHAR)

SELECT AVG(prominence) FROM mountain WHERE country = 'Morocco'


Question: What are the name, height and prominence of mountains which do not belong to the range 'Aberdare Range'?

Context: CREATE TABLE mountain (name VARCHAR, height VARCHAR, prominence VARCHAR, range VARCHAR)

SELECT name, height, prominence FROM mountain WHERE range <> 'Aberdare Range'


Question: What are the id and name of the photos for mountains?

Context: CREATE TABLE photos (mountain_id VARCHAR); CREATE TABLE mountain (id VARCHAR, name VARCHAR, height INTEGER)

SELECT T1.id, T1.name FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id WHERE T1.height > 4000


Question: What are the id and name of the mountains that have at least 2 photos?

Context: CREATE TABLE mountain (id VARCHAR, name VARCHAR); CREATE TABLE photos (mountain_id VARCHAR)

SELECT T1.id, T1.name FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id GROUP BY T1.id HAVING COUNT(*) >= 2


Question: What are the names of the cameras that have taken picture of the most mountains?

Context: CREATE TABLE camera_lens (name VARCHAR, id VARCHAR); CREATE TABLE photos (camera_lens_id VARCHAR)

SELECT T2.name FROM photos AS T1 JOIN camera_lens AS T2 ON T1.camera_lens_id = T2.id GROUP BY T2.id ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the names of photos taken with the lens brand 'Sigma' or 'Olympus'?

Context: CREATE TABLE photos (camera_lens_id VARCHAR); CREATE TABLE camera_lens (name VARCHAR, id VARCHAR, brand VARCHAR)

SELECT T1.name FROM camera_lens AS T1 JOIN photos AS T2 ON T2.camera_lens_id = T1.id WHERE T1.brand = 'Sigma' OR T1.brand = 'Olympus'


Question: How many different kinds of lens brands are there?

Context: CREATE TABLE camera_lens (brand VARCHAR)

SELECT COUNT(DISTINCT brand) FROM camera_lens


Question: How many camera lenses are not used in taking any photos?

Context: CREATE TABLE photos (id VARCHAR, camera_lens_id VARCHAR); CREATE TABLE camera_lens (id VARCHAR, camera_lens_id VARCHAR)

SELECT COUNT(*) FROM camera_lens WHERE NOT id IN (SELECT camera_lens_id FROM photos)


Question: How many distinct kinds of camera lenses are used to take photos of mountains in the country 'Ethiopia'?

Context: CREATE TABLE mountain (id VARCHAR, country VARCHAR); CREATE TABLE photos (camera_lens_id VARCHAR, mountain_id VARCHAR)

SELECT COUNT(DISTINCT T2.camera_lens_id) FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id WHERE T1.country = 'Ethiopia'


Question: List the brands of lenses that took both a picture of mountains with range 'Toubkal Atlas' and a picture of mountains with range 'Lasta Massif'

Context: CREATE TABLE mountain (id VARCHAR, range VARCHAR); CREATE TABLE photos (mountain_id VARCHAR, camera_lens_id VARCHAR); CREATE TABLE camera_lens (brand VARCHAR, id VARCHAR)

SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Toubkal Atlas' INTERSECT SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Lasta Massif'


Question: Show the name and prominence of the mountains whose picture is not taken by a lens of brand 'Sigma'.

Context: CREATE TABLE camera_lens (id VARCHAR, brand VARCHAR); CREATE TABLE mountain (name VARCHAR, prominence VARCHAR, id VARCHAR); CREATE TABLE photos (mountain_id VARCHAR, camera_lens_id VARCHAR); CREATE TABLE mountain (name VARCHAR, prominence VARCHAR)

SELECT name, prominence FROM mountain EXCEPT SELECT T1.name, T1.prominence FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T3.brand = 'Sigma'


Question: List the camera lens names containing substring "Digital".

Context: CREATE TABLE camera_lens (name VARCHAR)

SELECT name FROM camera_lens WHERE name LIKE "%Digital%"


Question: What is the name of each camera lens and the number of photos taken by it? Order the result by the count of photos.

Context: CREATE TABLE photos (camera_lens_id VARCHAR); CREATE TABLE camera_lens (name VARCHAR, id VARCHAR)

SELECT T1.name, COUNT(*) FROM camera_lens AS T1 JOIN photos AS T2 ON T1.id = T2.camera_lens_id GROUP BY T1.id ORDER BY COUNT(*)


Question: Find the names of channels that are not owned by CCTV.

Context: CREATE TABLE channel (name VARCHAR, OWNER VARCHAR)

SELECT name FROM channel WHERE OWNER <> 'CCTV'


Question: List all channel names ordered by their rating in percent from big to small.

Context: CREATE TABLE channel (name VARCHAR, rating_in_percent VARCHAR)

SELECT name FROM channel ORDER BY rating_in_percent DESC


Question: What is the owner of the channel that has the highest rating ratio?

Context: CREATE TABLE channel (OWNER VARCHAR, rating_in_percent VARCHAR)

SELECT OWNER FROM channel ORDER BY rating_in_percent DESC LIMIT 1


Question: how many programs are there?

Context: CREATE TABLE program (Id VARCHAR)


Question: list all the names of programs, ordering by launch time.

Context: CREATE TABLE program (name VARCHAR, launch VARCHAR)

SELECT name FROM program ORDER BY launch


Question: List the name, origin and owner of each program.

Context: CREATE TABLE program (name VARCHAR, origin VARCHAR, OWNER VARCHAR)


Question: find the name of the program that was launched most recently.

SELECT name FROM program ORDER BY launch DESC LIMIT 1


Question: find the total percentage share of all channels owned by CCTV.

Context: CREATE TABLE channel (Share_in_percent INTEGER, OWNER VARCHAR)

SELECT SUM(Share_in_percent) FROM channel WHERE OWNER = 'CCTV'


Question: Find the names of the channels that are broadcast in the morning.

Context: CREATE TABLE channel (name VARCHAR, channel_id VARCHAR); CREATE TABLE broadcast (channel_id VARCHAR, time_of_day VARCHAR)

SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning'


Question: what are the names of the channels that broadcast in both morning and night?

SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning' INTERSECT SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Night'


Question: how many programs are broadcast in each time section of the day?

Context: CREATE TABLE broadcast (time_of_day VARCHAR)

SELECT COUNT(*), time_of_day FROM broadcast GROUP BY time_of_day


Question: find the number of different programs that are broadcast during night time.

Context: CREATE TABLE broadcast (program_id VARCHAR, time_of_day VARCHAR)

SELECT COUNT(DISTINCT program_id) FROM broadcast WHERE time_of_day = 'Night'


Question: Find the names of programs that are never broadcasted in the morning.

Context: CREATE TABLE broadcast (program_id VARCHAR, Time_of_day VARCHAR); CREATE TABLE program (name VARCHAR, program_id VARCHAR); CREATE TABLE program (name VARCHAR)

SELECT name FROM program EXCEPT SELECT t1.name FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Morning"


Question: find the program owners that have some programs in both morning and night time.

Context: CREATE TABLE broadcast (program_id VARCHAR, Time_of_day VARCHAR); CREATE TABLE program (owner VARCHAR, program_id VARCHAR)

SELECT t1.owner FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Morning" INTERSECT SELECT t1.owner FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id WHERE t2.Time_of_day = "Night"


Question: List all program origins in the alphabetical order.

Context: CREATE TABLE program (origin VARCHAR)

SELECT origin FROM program ORDER BY origin


Question: what is the number of different channel owners?

Context: CREATE TABLE channel (OWNER VARCHAR)

SELECT COUNT(DISTINCT OWNER) FROM channel


Question: find the names of programs whose origin is not in Beijing.

Context: CREATE TABLE program (name VARCHAR, origin VARCHAR)

SELECT name FROM program WHERE origin <> 'Beijing'


Question: What are the names of the channels owned by CCTV or HBS?

SELECT name FROM channel WHERE OWNER = 'CCTV' OR OWNER = 'HBS'


Question: Find the total rating ratio for each channel owner.

Context: CREATE TABLE channel (OWNER VARCHAR, Rating_in_percent INTEGER)

SELECT SUM(Rating_in_percent), OWNER FROM channel GROUP BY OWNER


Question: Find the name of the program that is broadcast most frequently.

Context: CREATE TABLE program (name VARCHAR, program_id VARCHAR); CREATE TABLE broadcast (program_id VARCHAR)

SELECT t1.name FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id GROUP BY t2.program_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many courses are there in total?

Context: CREATE TABLE COURSES (Id VARCHAR)


Question: What are the descriptions of the courses with name "database"?

Context: CREATE TABLE COURSES (course_description VARCHAR, course_name VARCHAR)

SELECT course_description FROM COURSES WHERE course_name = "database"


Question: What are the addresses of the course authors or tutors with personal name "Cathrine"

Context: CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR, personal_name VARCHAR)

SELECT address_line_1 FROM Course_Authors_and_Tutors WHERE personal_name = "Cathrine"


Question: List the addresses of all the course authors or tutors.

Context: CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR)

SELECT address_line_1 FROM Course_Authors_and_Tutors


Question: List all the login names and family names of course author and tutors.

Context: CREATE TABLE Course_Authors_and_Tutors (login_name VARCHAR, family_name VARCHAR)

SELECT login_name, family_name FROM Course_Authors_and_Tutors


Question: List all the dates of enrollment and completion of students.

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, date_of_completion VARCHAR)

SELECT date_of_enrolment, date_of_completion FROM Student_Course_Enrolment


Question: How many distinct students are enrolled in courses?

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR)

SELECT COUNT(DISTINCT student_id) FROM Student_Course_Enrolment


Question: How many distinct courses are enrolled in by students?

Context: CREATE TABLE Student_Course_Enrolment (course_id VARCHAR)

SELECT COUNT(course_id) FROM Student_Course_Enrolment


Question: Find the dates of the tests taken with result "Pass".

Context: CREATE TABLE Student_Tests_Taken (date_test_taken VARCHAR, test_result VARCHAR)

SELECT date_test_taken FROM Student_Tests_Taken WHERE test_result = "Pass"


Question: How many tests have result "Fail"?

Context: CREATE TABLE Student_Tests_Taken (test_result VARCHAR)

SELECT COUNT(*) FROM Student_Tests_Taken WHERE test_result = "Fail"


Question: What are the login names of the students with family name "Ward"?

Context: CREATE TABLE Students (login_name VARCHAR, family_name VARCHAR)

SELECT login_name FROM Students WHERE family_name = "Ward"


Question: What are the dates of the latest logon of the students with family name "Jaskolski" or "Langosh"?

Context: CREATE TABLE Students (date_of_latest_logon VARCHAR, family_name VARCHAR)

SELECT date_of_latest_logon FROM Students WHERE family_name = "Jaskolski" OR family_name = "Langosh"


Question: How many students have personal names that contain the word "son"?

Context: CREATE TABLE Students (personal_name VARCHAR)

SELECT COUNT(*) FROM Students WHERE personal_name LIKE "%son%"


Question: List all the subject names.

Context: CREATE TABLE SUBJECTS (subject_name VARCHAR)


Question: List all the information about course authors and tutors in alphabetical order of the personal name.

Context: CREATE TABLE Course_Authors_and_Tutors (personal_name VARCHAR)

SELECT * FROM Course_Authors_and_Tutors ORDER BY personal_name


Question: List the personal names and family names of all the students in alphabetical order of family name.

Context: CREATE TABLE Students (personal_name VARCHAR, family_name VARCHAR)

SELECT personal_name, family_name FROM Students ORDER BY family_name


Question: List each test result and its count in descending order of count.

SELECT test_result, COUNT(*) FROM Student_Tests_Taken GROUP BY test_result ORDER BY COUNT(*) DESC


Question: Find the login name of the course author that teaches the course with name "advanced database".

Context: CREATE TABLE Courses (author_id VARCHAR, course_name VARCHAR); CREATE TABLE Course_Authors_and_Tutors (login_name VARCHAR, author_id VARCHAR)

SELECT T1.login_name FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T2.course_name = "advanced database"


Question: Find the addresses of the course authors who teach the course with name "operating system" or "data structure".

Context: CREATE TABLE Courses (author_id VARCHAR, course_name VARCHAR); CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR, author_id VARCHAR)

SELECT T1.address_line_1 FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T2.course_name = "operating system" OR T2.course_name = "data structure"


Question: Find the personal name, family name, and author ID of the course author that teaches the most courses.

Context: CREATE TABLE Courses (author_id VARCHAR); CREATE TABLE Course_Authors_and_Tutors (personal_name VARCHAR, family_name VARCHAR, author_id VARCHAR)

SELECT T1.personal_name, T1.family_name, T2.author_id FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id GROUP BY T2.author_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the addresses and author IDs of the course authors that teach at least two courses.

Context: CREATE TABLE Courses (author_id VARCHAR); CREATE TABLE Course_Authors_and_Tutors (address_line_1 VARCHAR, author_id VARCHAR)

SELECT T1.address_line_1, T2.author_id FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id GROUP BY T2.author_id HAVING COUNT(*) >= 2


Question: Find the names of courses taught by the tutor who has personal name "Julio".

Context: CREATE TABLE Course_Authors_and_Tutors (author_id VARCHAR, personal_name VARCHAR); CREATE TABLE Courses (course_name VARCHAR, author_id VARCHAR)

SELECT T2.course_name FROM Course_Authors_and_Tutors AS T1 JOIN Courses AS T2 ON T1.author_id = T2.author_id WHERE T1.personal_name = "Julio"


Question: Find the names and descriptions of courses that belong to the subject named "Computer Science".

Context: CREATE TABLE Courses (course_name VARCHAR, course_description VARCHAR, subject_id VARCHAR); CREATE TABLE Subjects (subject_id VARCHAR, subject_name VARCHAR)

SELECT T1.course_name, T1.course_description FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id WHERE T2.subject_name = "Computer Science"


Question: Find the subject ID, subject name, and the corresponding number of available courses for each subject.

Context: CREATE TABLE Courses (subject_id VARCHAR); CREATE TABLE Subjects (subject_name VARCHAR, subject_id VARCHAR)

SELECT T1.subject_id, T2.subject_name, COUNT(*) FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id GROUP BY T1.subject_id


Question: Find the subject ID, name of subject and the corresponding number of courses for each subject, and sort by the course count in ascending order.

SELECT T1.subject_id, T2.subject_name, COUNT(*) FROM Courses AS T1 JOIN Subjects AS T2 ON T1.subject_id = T2.subject_id GROUP BY T1.subject_id ORDER BY COUNT(*)


Question: What is the date of enrollment of the course named "Spanish"?

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, course_id VARCHAR); CREATE TABLE Courses (course_id VARCHAR, course_name VARCHAR)

SELECT T2.date_of_enrolment FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "Spanish"


Question: What is the name of the course that has the most student enrollment?

Context: CREATE TABLE Courses (course_name VARCHAR, course_id VARCHAR); CREATE TABLE Student_Course_Enrolment (course_id VARCHAR)

SELECT T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY COUNT(*) DESC LIMIT 1


Question: What are the names of the courses that have exactly 1 student enrollment?

SELECT T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) = 1


Question: What are the descriptions and names of the courses that have student enrollment bigger than 2?

Context: CREATE TABLE Student_Course_Enrolment (course_id VARCHAR); CREATE TABLE Courses (course_description VARCHAR, course_name VARCHAR, course_id VARCHAR)

SELECT T1.course_description, T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) > 2


Question: What is the name of each course and the corresponding number of student enrollment?

SELECT T1.course_name, COUNT(*) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name


Question: What are the enrollment dates of all the tests that have result "Pass"?

Context: CREATE TABLE Student_Tests_Taken (registration_id VARCHAR, test_result VARCHAR); CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, registration_id VARCHAR)

SELECT T1.date_of_enrolment FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Pass"


Question: What are the completion dates of all the tests that have result "Fail"?

Context: CREATE TABLE Student_Tests_Taken (registration_id VARCHAR, test_result VARCHAR); CREATE TABLE Student_Course_Enrolment (date_of_completion VARCHAR, registration_id VARCHAR)

SELECT T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Fail"


Question: List the dates of enrollment and completion of the student with personal name "Karson".

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, date_of_completion VARCHAR, student_id VARCHAR); CREATE TABLE Students (student_id VARCHAR, personal_name VARCHAR)

SELECT T1.date_of_enrolment, T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.personal_name = "Karson"


Question: List the dates of enrollment and completion of the student with family name "Zieme" and personal name "Bernie".

Context: CREATE TABLE Student_Course_Enrolment (date_of_enrolment VARCHAR, date_of_completion VARCHAR, student_id VARCHAR); CREATE TABLE Students (student_id VARCHAR, family_name VARCHAR, personal_name VARCHAR)

SELECT T1.date_of_enrolment, T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.family_name = "Zieme" AND T2.personal_name = "Bernie"


Question: Find the student ID and login name of the student with the most course enrollments

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (login_name VARCHAR, student_id VARCHAR)

SELECT T1.student_id, T2.login_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the student ID and personal name of the student with at least two enrollments.

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (personal_name VARCHAR, student_id VARCHAR)

SELECT T1.student_id, T2.personal_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) >= 2


Question: Find the student ID and middle name for all the students with at most two enrollments.

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (middle_name VARCHAR, student_id VARCHAR)

SELECT T1.student_id, T2.middle_name FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id HAVING COUNT(*) <= 2


Question: Find the personal names of students not enrolled in any course.

Context: CREATE TABLE Student_Course_Enrolment (student_id VARCHAR); CREATE TABLE Students (personal_name VARCHAR); CREATE TABLE Students (personal_name VARCHAR, student_id VARCHAR)

SELECT personal_name FROM Students EXCEPT SELECT T1.personal_name FROM Students AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.student_id = T2.student_id


Question: How many students did not have any course enrollment?

Context: CREATE TABLE Students (student_id VARCHAR); CREATE TABLE Student_Course_Enrolment (student_id VARCHAR)

SELECT COUNT(*) FROM Students WHERE NOT student_id IN (SELECT student_id FROM Student_Course_Enrolment)


Question: Find the common login name of course authors and students.

Context: CREATE TABLE Course_Authors_and_Tutors (login_name VARCHAR); CREATE TABLE Students (login_name VARCHAR)

SELECT login_name FROM Course_Authors_and_Tutors INTERSECT SELECT login_name FROM Students


Question: Find the common personal name of course authors and students.

Context: CREATE TABLE Course_Authors_and_Tutors (personal_name VARCHAR); CREATE TABLE Students (personal_name VARCHAR)

SELECT personal_name FROM Course_Authors_and_Tutors INTERSECT SELECT personal_name FROM Students


Question: Which claims caused more than 2 settlements or have the maximum claim value? List the date the claim was made and the claim id.

Context: CREATE TABLE Settlements (Claim_id VARCHAR); CREATE TABLE Claims (Amount_Claimed INTEGER); CREATE TABLE Claims (Date_Claim_Made VARCHAR, Claim_id VARCHAR, Amount_Claimed INTEGER)

SELECT T1.Date_Claim_Made, T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.Claim_id HAVING COUNT(*) > 2 UNION SELECT T1.Date_Claim_Made, T1.Claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id WHERE T1.Amount_Claimed = (SELECT MAX(Amount_Claimed) FROM Claims)


Question: Which customer had at least 2 policies but did not file any claims? List the customer details and id.

Context: CREATE TABLE Customers (customer_details VARCHAR, customer_id VARCHAR, Customer_id VARCHAR); CREATE TABLE Customer_Policies (customer_id VARCHAR, policy_id VARCHAR); CREATE TABLE Claims (policy_id VARCHAR)

SELECT T1.customer_details, T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id = T2.customer_id GROUP BY T1.customer_id HAVING COUNT(*) >= 2 EXCEPT SELECT T1.customer_details, T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id = T2.customer_id JOIN Claims AS T3 ON T2.policy_id = T3.policy_id


Question: List the method, date and amount of all the payments, in ascending order of date.

Context: CREATE TABLE Payments (Payment_Method_Code VARCHAR, Date_Payment_Made VARCHAR, Amount_Payment VARCHAR)

SELECT Payment_Method_Code, Date_Payment_Made, Amount_Payment FROM Payments ORDER BY Date_Payment_Made


Question: Among all the claims, what is the settlement amount of the claim with the largest claim amount? List both the settlement amount and claim amount.

Context: CREATE TABLE Claims (Amount_Settled VARCHAR, Amount_Claimed VARCHAR)

SELECT Amount_Settled, Amount_Claimed FROM Claims ORDER BY Amount_Claimed DESC LIMIT 1


Question: Among all the claims, what is the amount claimed in the claim with the least amount settled? List both the settlement amount and claim amount.

SELECT Amount_Settled, Amount_Claimed FROM Claims ORDER BY Amount_Settled LIMIT 1


Question: Among all the claims, which claims have a claimed amount larger than the average? List the date the claim was made and the date it was settled.

Context: CREATE TABLE Claims (Date_Claim_Made VARCHAR, Date_Claim_Settled VARCHAR, Amount_Claimed INTEGER)

SELECT Date_Claim_Made, Date_Claim_Settled FROM Claims WHERE Amount_Claimed > (SELECT AVG(Amount_Claimed) FROM Claims)


Question: Among all the claims, which settlements have a claimed amount that is no more than the average? List the claim start date.

Context: CREATE TABLE Claims (Date_Claim_Made VARCHAR, Amount_Settled INTEGER)

SELECT Date_Claim_Made FROM Claims WHERE Amount_Settled <= (SELECT AVG(Amount_Settled) FROM Claims)


Question: How many settlements does each claim correspond to? List the claim id and the number of settlements.

Context: CREATE TABLE Settlements (claim_id VARCHAR); CREATE TABLE Claims (Claim_id VARCHAR, claim_id VARCHAR)

SELECT T1.Claim_id, COUNT(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id


Question: Which claim incurred the most number of settlements? List the claim id, the date the claim was made, and the number.

Context: CREATE TABLE Claims (claim_id VARCHAR, date_claim_made VARCHAR); CREATE TABLE Settlements (claim_id VARCHAR)

SELECT T1.claim_id, T1.date_claim_made, COUNT(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY COUNT(*) DESC LIMIT 1


Question: How many settlements were made on the claim with the most recent claim settlement date? List the number and the claim id.

Context: CREATE TABLE Settlements (claim_id VARCHAR); CREATE TABLE Claims (claim_id VARCHAR, Date_Claim_Settled VARCHAR)

SELECT COUNT(*), T1.claim_id FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY T1.Date_Claim_Settled DESC LIMIT 1


Question: Of all the claims, what was the earliest date when any claim was made?

Context: CREATE TABLE Claims (Date_Claim_Made VARCHAR)

SELECT Date_Claim_Made FROM Claims ORDER BY Date_Claim_Made LIMIT 1


Question: What is the total amount of settlement made for all the settlements?

Context: CREATE TABLE Settlements (Amount_Settled INTEGER)

SELECT SUM(Amount_Settled) FROM Settlements


Question: Who are the customers that had more than 1 policy? List the customer details and id.

Context: CREATE TABLE Customers (customer_details VARCHAR, customer_id VARCHAR, Customer_id VARCHAR); CREATE TABLE Customer_Policies (Customer_id VARCHAR)

SELECT T1.customer_details, T1.customer_id FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.Customer_id = T2.Customer_id GROUP BY T1.customer_id HAVING COUNT(*) > 1


Question: What are the claim dates and settlement dates of all the settlements?

Context: CREATE TABLE Settlements (Date_Claim_Made VARCHAR, Date_Claim_Settled VARCHAR)

SELECT Date_Claim_Made, Date_Claim_Settled FROM Settlements


Question: What is the most popular payment method?

Context: CREATE TABLE Payments (Payment_Method_Code VARCHAR)

SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY COUNT(*) DESC LIMIT 1


Question: With which kind of payment method were the least number of payments processed?

SELECT Payment_Method_Code FROM Payments GROUP BY Payment_Method_Code ORDER BY COUNT(*) LIMIT 1


Question: What is the total amount of payment?

Context: CREATE TABLE Payments (Amount_Payment INTEGER)

SELECT SUM(Amount_Payment) FROM Payments


Question: What are all the distinct details of the customers?

Context: CREATE TABLE Customers (customer_details VARCHAR)

SELECT DISTINCT customer_details FROM Customers


Question: Which kind of policy type was chosen by the most customers?

Context: CREATE TABLE Customer_Policies (Policy_Type_Code VARCHAR)

SELECT Policy_Type_Code FROM Customer_Policies GROUP BY Policy_Type_Code ORDER BY COUNT(*) DESC LIMIT 1


Question: How many settlements are there in total?

Context: CREATE TABLE Settlements (Id VARCHAR)


Question: Which Payments were processed with Visa? List the payment Id, the date and the amount.

Context: CREATE TABLE Payments (Payment_ID VARCHAR, Date_Payment_Made VARCHAR, Amount_Payment VARCHAR, Payment_Method_Code VARCHAR)

SELECT Payment_ID, Date_Payment_Made, Amount_Payment FROM Payments WHERE Payment_Method_Code = 'Visa'


Question: List the details of the customers who do not have any policies.

Context: CREATE TABLE Customer_Policies (customer_id VARCHAR); CREATE TABLE Customers (customer_details VARCHAR, customer_id VARCHAR); CREATE TABLE Customers (customer_details VARCHAR)

SELECT customer_details FROM Customers EXCEPT SELECT T1.customer_details FROM Customers AS T1 JOIN Customer_Policies AS T2 ON T1.customer_id = T2.customer_id


Question: List the date the claim was made, the date it was settled and the amount settled for all the claims which had exactly one settlement.

Context: CREATE TABLE Claims (claim_id VARCHAR, date_claim_made VARCHAR, Date_Claim_Settled VARCHAR, Claim_id VARCHAR); CREATE TABLE Settlements (Claim_id VARCHAR)

SELECT T1.claim_id, T1.date_claim_made, T1.Date_Claim_Settled FROM Claims AS T1 JOIN Settlements AS T2 ON T1.Claim_id = T2.Claim_id GROUP BY T1.claim_id HAVING COUNT(*) = 1


Question: Find the total claimed amount of all the claims.

Context: CREATE TABLE Claims (Amount_Claimed INTEGER)


Question: Which department has the largest number of employees?

Context: CREATE TABLE department (name VARCHAR, departmentID VARCHAR)

SELECT name FROM department GROUP BY departmentID ORDER BY COUNT(departmentID) DESC LIMIT 1


Question: What is the employee id of the head whose department has the least number of employees?

Context: CREATE TABLE department (head VARCHAR, departmentID VARCHAR)

SELECT head FROM department GROUP BY departmentID ORDER BY COUNT(departmentID) LIMIT 1


Question: what is the name and position of the head whose department has least number of employees?

Context: CREATE TABLE department (head VARCHAR); CREATE TABLE physician (name VARCHAR, position VARCHAR, EmployeeID VARCHAR)

SELECT T2.name, T2.position FROM department AS T1 JOIN physician AS T2 ON T1.head = T2.EmployeeID GROUP BY departmentID ORDER BY COUNT(departmentID) LIMIT 1


Question: What are names of patients who made an appointment?

Context: CREATE TABLE appointment (patient VARCHAR); CREATE TABLE patient (ssn VARCHAR)

SELECT name FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn


Question: what are name and phone number of patients who had more than one appointment?

SELECT name, phone FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn GROUP BY T1.patient HAVING COUNT(*) > 1


Question: Find the id of the appointment with the most recent start date?

Context: CREATE TABLE appointment (appointmentid VARCHAR, START VARCHAR)

SELECT appointmentid FROM appointment ORDER BY START DESC LIMIT 1


Question: List the name of physicians who took some appointment.

Context: CREATE TABLE appointment (Physician VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID


Question: List the name of physicians who never took any appointment.

Context: CREATE TABLE physician (name VARCHAR); CREATE TABLE appointment (Physician VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

SELECT name FROM physician EXCEPT SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID


Question: Find the names of all physicians and their primary affiliated departments' names.

Context: CREATE TABLE department (name VARCHAR, DepartmentID VARCHAR); CREATE TABLE affiliated_with (physician VARCHAR, department VARCHAR, PrimaryAffiliation VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

SELECT T1.name, T3.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T2.PrimaryAffiliation = 1


Question: What is the name of the patient who made the most recent appointment?

Context: CREATE TABLE patient (name VARCHAR, ssn VARCHAR); CREATE TABLE appointment (patient VARCHAR, start VARCHAR)

SELECT T1.name FROM patient AS T1 JOIN appointment AS T2 ON T1.ssn = T2.patient ORDER BY T2.start DESC LIMIT 1


Question: How many patients stay in room 112?

Context: CREATE TABLE stay (patient VARCHAR, room VARCHAR)

SELECT COUNT(patient) FROM stay WHERE room = 112


Question: How many patients' prescriptions are made by physician John Dorian?

Context: CREATE TABLE patient (SSN VARCHAR); CREATE TABLE prescribes (patient VARCHAR, physician VARCHAR); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR)

SELECT COUNT(T1.SSN) FROM patient AS T1 JOIN prescribes AS T2 ON T1.SSN = T2.patient JOIN physician AS T3 ON T2.physician = T3.employeeid WHERE T3.name = "John Dorian"


Question: Find the name of medication used on the patient who stays in room 111?

Context: CREATE TABLE Prescribes (Patient VARCHAR, Medication VARCHAR); CREATE TABLE Medication (name VARCHAR, Code VARCHAR); CREATE TABLE patient (SSN VARCHAR); CREATE TABLE stay (Patient VARCHAR)

SELECT T4.name FROM stay AS T1 JOIN patient AS T2 ON T1.Patient = T2.SSN JOIN Prescribes AS T3 ON T3.Patient = T2.SSN JOIN Medication AS T4 ON T3.Medication = T4.Code WHERE room = 111


Question: Find the patient who most recently stayed in room 111.

Context: CREATE TABLE stay (patient VARCHAR, room VARCHAR, staystart VARCHAR)

SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1


Question: What is the name of the nurse has the most appointments?

Context: CREATE TABLE nurse (name VARCHAR, employeeid VARCHAR); CREATE TABLE appointment (prepnurse VARCHAR)

SELECT T1.name FROM nurse AS T1 JOIN appointment AS T2 ON T1.employeeid = T2.prepnurse GROUP BY T1.employeeid ORDER BY COUNT(*) DESC LIMIT 1


Question: How many patients do each physician take care of? List their names and number of patients they take care of.

Context: CREATE TABLE patient (PCP VARCHAR); CREATE TABLE physician (name VARCHAR, employeeid VARCHAR)

SELECT T1.name, COUNT(*) FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid


Question: Find the name of physicians who are in charge of more than one patient.

SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING COUNT(*) > 1


Question: Find the number of rooms located on each block floor.

Context: CREATE TABLE room (blockfloor VARCHAR, blockcode VARCHAR); CREATE TABLE BLOCK (blockfloor VARCHAR, blockcode VARCHAR)

SELECT COUNT(*), T1.blockfloor FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockfloor


Question: Find the number of rooms for different block code?

Context: CREATE TABLE room (blockfloor VARCHAR, blockcode VARCHAR); CREATE TABLE BLOCK (blockcode VARCHAR, blockfloor VARCHAR)

SELECT COUNT(*), T1.blockcode FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockcode


Question: What are the unique block codes that have available rooms?

Context: CREATE TABLE room (blockcode VARCHAR, unavailable VARCHAR)

SELECT DISTINCT blockcode FROM room WHERE unavailable = 0


Question: How many different types of rooms are there?

Context: CREATE TABLE room (roomtype VARCHAR)

SELECT COUNT(DISTINCT roomtype) FROM room


Question: What is the names of the physicians who prescribe medication Thesisin?

Context: CREATE TABLE physician (name VARCHAR, employeeid VARCHAR); CREATE TABLE prescribes (physician VARCHAR, medication VARCHAR); CREATE TABLE medication (code VARCHAR, name VARCHAR)

SELECT DISTINCT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.name = "Thesisin"


Question: Find the name and position of physicians who prescribe some medication whose brand is X?

Context: CREATE TABLE medication (code VARCHAR, Brand VARCHAR); CREATE TABLE prescribes (physician VARCHAR, medication VARCHAR); CREATE TABLE physician (name VARCHAR, position VARCHAR, employeeid VARCHAR)

SELECT DISTINCT T1.name, T1.position FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.Brand = "X"


Question: Find the number of medications prescribed for each brand.

Context: CREATE TABLE medication (name VARCHAR, brand VARCHAR, code VARCHAR); CREATE TABLE prescribes (medication VARCHAR)

SELECT COUNT(*), T1.name FROM medication AS T1 JOIN prescribes AS T2 ON T1.code = T2.medication GROUP BY T1.brand


Question: Find the name of physicians whose position title contains the word 'senior'.

Context: CREATE TABLE physician (name VARCHAR, POSITION VARCHAR)

SELECT name FROM physician WHERE POSITION LIKE '%senior%'


Question: Find the patient who has the most recent undergoing treatment?

Context: CREATE TABLE undergoes (patient VARCHAR, dateundergoes VARCHAR)

SELECT patient FROM undergoes ORDER BY dateundergoes LIMIT 1


Question: Find the names of all patients who have an undergoing treatment and are staying in room 111.

Context: CREATE TABLE undergoes (patient VARCHAR, Stay VARCHAR); CREATE TABLE stay (StayID VARCHAR, room VARCHAR); CREATE TABLE patient (name VARCHAR, SSN VARCHAR)

SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN patient AS T2 ON T1.patient = T2.SSN JOIN stay AS T3 ON T1.Stay = T3.StayID WHERE T3.room = 111


Question: List the names of all distinct nurses ordered by alphabetical order?

Context: CREATE TABLE nurse (name VARCHAR)

SELECT DISTINCT name FROM nurse ORDER BY name


Question: Find the names of nurses who are nursing an undergoing treatment.

Context: CREATE TABLE undergoes (AssistingNurse VARCHAR); CREATE TABLE nurse (name VARCHAR, EmployeeID VARCHAR)

SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN nurse AS T2 ON T1.AssistingNurse = T2.EmployeeID


Question: List the names of all distinct medications, ordered in an alphabetical order.

Context: CREATE TABLE medication (name VARCHAR)

SELECT DISTINCT name FROM medication ORDER BY name


Question: What are the names of the physician who prescribed the highest dose?

Context: CREATE TABLE prescribes (physician VARCHAR, dose VARCHAR); CREATE TABLE physician (name VARCHAR, employeeid VARCHAR)

SELECT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician ORDER BY T2.dose DESC LIMIT 1


Question: List the physicians' employee ids together with their primary affiliation departments' ids.

Context: CREATE TABLE affiliated_with (physician VARCHAR, department VARCHAR, primaryaffiliation VARCHAR)

SELECT physician, department FROM affiliated_with WHERE primaryaffiliation = 1


Question: List the names of departments where some physicians are primarily affiliated with.

Context: CREATE TABLE affiliated_with (department VARCHAR); CREATE TABLE department (name VARCHAR, departmentid VARCHAR)

SELECT DISTINCT T2.name FROM affiliated_with AS T1 JOIN department AS T2 ON T1.department = T2.departmentid WHERE PrimaryAffiliation = 1


Question: What nurses are on call with block floor 1 and block code 1? Tell me their names.

Context: CREATE TABLE on_call (nurse VARCHAR, blockfloor VARCHAR, blockcode VARCHAR)

SELECT nurse FROM on_call WHERE blockfloor = 1 AND blockcode = 1


Question: What are the highest cost, lowest cost and average cost of procedures?

Context: CREATE TABLE procedures (cost INTEGER)

SELECT MAX(cost), MIN(cost), AVG(cost) FROM procedures


Question: List the name and cost of all procedures sorted by the cost from the highest to the lowest.

Context: CREATE TABLE procedures (name VARCHAR, cost VARCHAR)

SELECT name, cost FROM procedures ORDER BY cost DESC


Question: Find the three most expensive procedures.

SELECT name FROM procedures ORDER BY cost LIMIT 3


Question: Find the physicians who are trained in a procedure that costs more than 5000.

Context: CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE physician (name VARCHAR, employeeid VARCHAR); CREATE TABLE procedures (code VARCHAR, cost INTEGER)

SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T3.cost > 5000


Question: Find the physician who was trained in the most expensive procedure?

Context: CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE physician (name VARCHAR, employeeid VARCHAR); CREATE TABLE procedures (code VARCHAR, cost VARCHAR)

SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment ORDER BY T3.cost DESC LIMIT 1


Question: What is the average cost of procedures that physician John Wen was trained in?

Context: CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE procedures (cost INTEGER, code VARCHAR); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR)

SELECT AVG(T3.cost) FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen"


Question: Find the names of procedures which physician John Wen was trained in.

Context: CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR); CREATE TABLE procedures (name VARCHAR, code VARCHAR)

SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen"


Question: Find all procedures which cost more than 1000 or which physician John Wen was trained in.

Context: CREATE TABLE trained_in (physician VARCHAR, treatment VARCHAR); CREATE TABLE procedures (name VARCHAR, cost INTEGER); CREATE TABLE physician (employeeid VARCHAR, name VARCHAR); CREATE TABLE procedures (name VARCHAR, code VARCHAR)

SELECT name FROM procedures WHERE cost > 1000 UNION SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen"


Question: Find the names of all procedures which cost more than 1000 but which physician John Wen was not trained in?

SELECT name FROM procedures WHERE cost > 1000 EXCEPT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen"


Question: Find the names of all procedures such that the cost is less than 5000 and physician John Wen was trained in.

SELECT name FROM procedures WHERE cost < 5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid = T2.physician JOIN procedures AS T3 ON T3.code = T2.treatment WHERE T1.name = "John Wen"


Question: Find the name of physicians who are affiliated with both Surgery and Psychiatry departments.

Context: CREATE TABLE affiliated_with (physician VARCHAR, department VARCHAR); CREATE TABLE department (DepartmentID VARCHAR, name VARCHAR); CREATE TABLE physician (name VARCHAR, EmployeeID VARCHAR)

SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T3.name = 'Surgery' INTERSECT SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T3.name = 'Psychiatry'


Question: Find the name of physicians who are affiliated with Surgery or Psychiatry department.

SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T3.name = 'Surgery' OR T3.name = 'Psychiatry'


Question: Find the names of patients who are not using the medication of Procrastin-X.

Context: CREATE TABLE Prescribes (Patient VARCHAR, Medication VARCHAR); CREATE TABLE Medication (Code VARCHAR, name VARCHAR); CREATE TABLE patient (name VARCHAR, SSN VARCHAR); CREATE TABLE patient (name VARCHAR)

SELECT name FROM patient EXCEPT SELECT T1.name FROM patient AS T1 JOIN Prescribes AS T2 ON T2.Patient = T1.SSN JOIN Medication AS T3 ON T2.Medication = T3.Code WHERE T3.name = 'Procrastin-X'


Question: Find the number of patients who are not using the medication of Procrastin-X.

Context: CREATE TABLE Prescribes (patient VARCHAR, Medication VARCHAR); CREATE TABLE patient (SSN VARCHAR); CREATE TABLE Medication (Code VARCHAR, name VARCHAR)

SELECT COUNT(*) FROM patient WHERE NOT SSN IN (SELECT T1.patient FROM Prescribes AS T1 JOIN Medication AS T2 ON T1.Medication = T2.Code WHERE T2.name = 'Procrastin-X')


Question: How many appointments are there?

Context: CREATE TABLE appointment (Id VARCHAR)


Question: Find the names of nurses who are on call.

Context: CREATE TABLE on_call (nurse VARCHAR); CREATE TABLE nurse (name VARCHAR, EmployeeID VARCHAR)

SELECT DISTINCT T1.name FROM nurse AS T1 JOIN on_call AS T2 ON T1.EmployeeID = T2.nurse


Question: How many ships are there?

Context: CREATE TABLE ship (Id VARCHAR)


Question: List the name of ships in ascending order of tonnage.

Context: CREATE TABLE ship (Name VARCHAR, Tonnage VARCHAR)


Question: What are the type and nationality of ships?

Context: CREATE TABLE ship (TYPE VARCHAR, Nationality VARCHAR)


Question: List the name of ships whose nationality is not "United States".

Context: CREATE TABLE ship (Name VARCHAR, Nationality VARCHAR)

SELECT Name FROM ship WHERE Nationality <> "United States"


Question: Show the name of ships whose nationality is either United States or United Kingdom.

SELECT Name FROM ship WHERE Nationality = "United States" OR Nationality = "United Kingdom"


Question: What is the name of the ship with the largest tonnage?

SELECT Name FROM ship ORDER BY Tonnage DESC LIMIT 1


Question: Show different types of ships and the number of ships of each type.

Context: CREATE TABLE ship (TYPE VARCHAR)

SELECT TYPE, COUNT(*) FROM ship GROUP BY TYPE


Question: Please show the most common type of ships.

Context: CREATE TABLE ship (TYPE VARCHAR)

SELECT TYPE FROM ship GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1


Question: List the nations that have more than two ships.

Context: CREATE TABLE ship (Nationality VARCHAR)

SELECT Nationality FROM ship GROUP BY Nationality HAVING COUNT(*) > 2


Question: Show different types of ships and the average tonnage of ships of each type.

Context: CREATE TABLE ship (TYPE VARCHAR, Tonnage INTEGER)

SELECT TYPE, AVG(Tonnage) FROM ship GROUP BY TYPE


Question: Show codes and fates of missions, and names of ships involved.

Context: CREATE TABLE mission (Code VARCHAR, Fate VARCHAR, Ship_ID VARCHAR); CREATE TABLE ship (Name VARCHAR, Ship_ID VARCHAR)

SELECT T1.Code, T1.Fate, T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID


Question: Show names of ships involved in a mission launched after 1928.

Context: CREATE TABLE mission (Ship_ID VARCHAR, Launched_Year INTEGER); CREATE TABLE ship (Name VARCHAR, Ship_ID VARCHAR)

SELECT T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID WHERE T1.Launched_Year > 1928


Question: Show the distinct fate of missions that involve ships with nationality "United States"

Context: CREATE TABLE mission (Fate VARCHAR, Ship_ID VARCHAR); CREATE TABLE ship (Ship_ID VARCHAR, Nationality VARCHAR)

SELECT DISTINCT T1.Fate FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID = T2.Ship_ID WHERE T2.Nationality = "United States"


Question: List the name of ships that are not involved in any mission

Context: CREATE TABLE mission (Name VARCHAR, Ship_ID VARCHAR); CREATE TABLE ship (Name VARCHAR, Ship_ID VARCHAR)

SELECT Name FROM ship WHERE NOT Ship_ID IN (SELECT Ship_ID FROM mission)


Question: Show the types of ships that have both ships with tonnage larger than 6000 and ships with tonnage smaller than 4000.

SELECT TYPE FROM ship WHERE Tonnage > 6000 INTERSECT SELECT TYPE FROM ship WHERE Tonnage < 4000


Question: Find the number of students in total.

Context: CREATE TABLE list (Id VARCHAR)


Question: Find the last names of students studying in room 111.

Context: CREATE TABLE list (lastname VARCHAR, classroom VARCHAR)

SELECT lastname FROM list WHERE classroom = 111


Question: Find the first names of students studying in room 108.

Context: CREATE TABLE list (firstname VARCHAR, classroom VARCHAR)

SELECT firstname FROM list WHERE classroom = 108


Question: What are the first names of students studying in room 107?

SELECT DISTINCT firstname FROM list WHERE classroom = 107


Question: For each classroom report the grade that is taught in it. Report just the classroom number and the grade number.

Context: CREATE TABLE list (classroom VARCHAR, grade VARCHAR)

SELECT DISTINCT classroom, grade FROM list


Question: Which grade is studying in classroom 103?

Context: CREATE TABLE list (grade VARCHAR, classroom VARCHAR)

SELECT DISTINCT grade FROM list WHERE classroom = 103


Question: Find the grade studying in room 105.

SELECT DISTINCT grade FROM list WHERE classroom = 105


Question: Which classrooms are used by grade 4?

SELECT DISTINCT classroom FROM list WHERE grade = 4


Question: Which classrooms are used by grade 5?

SELECT DISTINCT classroom FROM list WHERE grade = 5


Question: Find the last names of the teachers that teach fifth grade.

Context: CREATE TABLE list (classroom VARCHAR); CREATE TABLE teachers (lastname VARCHAR, classroom VARCHAR)

SELECT DISTINCT T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE grade = 5


Question: Find the first names of the teachers that teach first grade.

Context: CREATE TABLE list (classroom VARCHAR); CREATE TABLE teachers (firstname VARCHAR, classroom VARCHAR)

SELECT DISTINCT T2.firstname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE grade = 1


Question: Find the first names of all the teachers that teach in classroom 110.

Context: CREATE TABLE teachers (firstname VARCHAR, classroom VARCHAR)

SELECT firstname FROM teachers WHERE classroom = 110


Question: Find the last names of teachers teaching in classroom 109.

Context: CREATE TABLE teachers (lastname VARCHAR, classroom VARCHAR)

SELECT lastname FROM teachers WHERE classroom = 109


Question: Report the first name and last name of all the teachers.

Context: CREATE TABLE teachers (firstname VARCHAR, lastname VARCHAR)

SELECT DISTINCT firstname, lastname FROM teachers


Question: Report the first name and last name of all the students.

Context: CREATE TABLE list (firstname VARCHAR, lastname VARCHAR)

SELECT DISTINCT firstname, lastname FROM list


Question: Find all students taught by OTHA MOYER. Output the first and last names of the students.

Context: CREATE TABLE list (firstname VARCHAR, lastname VARCHAR, classroom VARCHAR); CREATE TABLE teachers (classroom VARCHAR, firstname VARCHAR, lastname VARCHAR)

SELECT T1.firstname, T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "OTHA" AND T2.lastname = "MOYER"


Question: Find all students taught by MARROTTE KIRK. Output first and last names of students.

SELECT T1.firstname, T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "MARROTTE" AND T2.lastname = "KIRK"


Question: Find the first and last name of all the teachers that teach EVELINA BROMLEY.

Context: CREATE TABLE teachers (firstname VARCHAR, lastname VARCHAR, classroom VARCHAR); CREATE TABLE list (classroom VARCHAR, firstname VARCHAR, lastname VARCHAR)

SELECT T2.firstname, T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.firstname = "EVELINA" AND T1.lastname = "BROMLEY"


Question: Find the last names of all the teachers that teach GELL TAMI.

Context: CREATE TABLE teachers (lastname VARCHAR, classroom VARCHAR); CREATE TABLE list (classroom VARCHAR, firstname VARCHAR, lastname VARCHAR)

SELECT T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.firstname = "GELL" AND T1.lastname = "TAMI"


Question: How many students does LORIA ONDERSMA teaches?

Context: CREATE TABLE list (classroom VARCHAR); CREATE TABLE teachers (classroom VARCHAR, firstname VARCHAR, lastname VARCHAR)

SELECT COUNT(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "LORIA" AND T2.lastname = "ONDERSMA"


Question: How many students does KAWA GORDON teaches?

SELECT COUNT(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "KAWA" AND T2.lastname = "GORDON"


Question: Find the number of students taught by TARRING LEIA.

SELECT COUNT(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "TARRING" AND T2.lastname = "LEIA"


Question: How many teachers does the student named CHRISSY NABOZNY have?

Context: CREATE TABLE teachers (classroom VARCHAR); CREATE TABLE list (classroom VARCHAR, firstname VARCHAR, lastname VARCHAR)

SELECT COUNT(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.firstname = "CHRISSY" AND T1.lastname = "NABOZNY"


Question: How many teachers does the student named MADLOCK RAY have?

SELECT COUNT(*) FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.firstname = "MADLOCK" AND T1.lastname = "RAY"


Question: Find all first-grade students who are NOT taught by OTHA MOYER. Report their first and last names.

Context: CREATE TABLE list (firstname VARCHAR, lastname VARCHAR, classroom VARCHAR, grade VARCHAR); CREATE TABLE teachers (classroom VARCHAR, firstname VARCHAR, lastname VARCHAR)

SELECT DISTINCT T1.firstname, T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.grade = 1 EXCEPT SELECT T1.firstname, T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T2.firstname = "OTHA" AND T2.lastname = "MOYER"


Question: Find the last names of the students in third grade that are not taught by COVIN JEROME.

Context: CREATE TABLE list (lastname VARCHAR, classroom VARCHAR, grade VARCHAR); CREATE TABLE teachers (classroom VARCHAR, lastname VARCHAR, firstname VARCHAR)

SELECT DISTINCT T1.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom WHERE T1.grade = 3 AND T2.firstname <> "COVIN" AND T2.lastname <> "JEROME"


Question: For each grade, report the grade, the number of classrooms in which it is taught and the total number of students in the grade.

SELECT grade, COUNT(DISTINCT classroom), COUNT(*) FROM list GROUP BY grade


Question: For each classroom, report the classroom number and the number of grades using it.

SELECT classroom, COUNT(DISTINCT grade) FROM list GROUP BY classroom


Question: Which classroom has the most students?

Context: CREATE TABLE list (classroom VARCHAR)

SELECT classroom FROM list GROUP BY classroom ORDER BY COUNT(*) DESC LIMIT 1


Question: Report the number of students in each classroom.

Context: CREATE TABLE list (classroom VARCHAR)

SELECT classroom, COUNT(*) FROM list GROUP BY classroom


Question: For each grade 0 classroom, report the total number of students.

SELECT classroom, COUNT(*) FROM list WHERE grade = "0" GROUP BY classroom


Question: Report the total number of students for each fourth-grade classroom.

SELECT classroom, COUNT(*) FROM list WHERE grade = "4" GROUP BY classroom


Question: Find the name of the teacher who teaches the largest number of students.

Context: CREATE TABLE list (classroom VARCHAR); CREATE TABLE teachers (firstname VARCHAR, lastname VARCHAR, classroom VARCHAR)

SELECT T2.firstname, T2.lastname FROM list AS T1 JOIN teachers AS T2 ON T1.classroom = T2.classroom GROUP BY T2.firstname, T2.lastname ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the number of students in one classroom.

Context: CREATE TABLE list (classroom VARCHAR)

SELECT COUNT(*), classroom FROM list GROUP BY classroom


Question: How many companies are headquartered in the US?

Context: CREATE TABLE company (Headquarters VARCHAR)

SELECT COUNT(*) FROM company WHERE Headquarters = 'USA'


Question: List the names of companies by ascending number of sales.

Context: CREATE TABLE company (Name VARCHAR, Sales_in_Billion VARCHAR)

SELECT Name FROM company ORDER BY Sales_in_Billion


Question: What are the headquarters and industries of all companies?

Context: CREATE TABLE company (Headquarters VARCHAR, Industry VARCHAR)

SELECT Headquarters, Industry FROM company


Question: Show the names of companies in the banking or retailing industry?

Context: CREATE TABLE company (Name VARCHAR, Industry VARCHAR)

SELECT Name FROM company WHERE Industry = "Banking" OR Industry = "Retailing"


Question: What is the maximum and minimum market value of companies?

Context: CREATE TABLE company (Market_Value_in_Billion INTEGER)

SELECT MAX(Market_Value_in_Billion), MIN(Market_Value_in_Billion) FROM company


Question: What is the headquarter of the company with the largest sales?

Context: CREATE TABLE company (Headquarters VARCHAR, Sales_in_Billion VARCHAR)

SELECT Headquarters FROM company ORDER BY Sales_in_Billion DESC LIMIT 1


Question: Show the different headquarters and number of companies at each headquarter.

SELECT Headquarters, COUNT(*) FROM company GROUP BY Headquarters


Question: Show the most common headquarter for companies.

SELECT Headquarters FROM company GROUP BY Headquarters ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the headquarters that have at least two companies.

SELECT Headquarters FROM company GROUP BY Headquarters HAVING COUNT(*) >= 2


Question: Show the headquarters that have both companies in banking industry and companies in oil and gas industry.

SELECT Headquarters FROM company WHERE Industry = "Banking" INTERSECT SELECT Headquarters FROM company WHERE Industry = "Oil and gas"


Question: Show the names of companies and of employees.

Context: CREATE TABLE company (Name VARCHAR, Company_ID VARCHAR); CREATE TABLE employment (People_ID VARCHAR, Company_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T3.Name, T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID


Question: Show names of companies and that of employees in descending order of number of years working for that employee.

Context: CREATE TABLE people (Name VARCHAR, People_ID VARCHAR); CREATE TABLE company (Name VARCHAR, Company_ID VARCHAR); CREATE TABLE employment (People_ID VARCHAR, Company_ID VARCHAR, Year_working VARCHAR)

SELECT T3.Name, T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID ORDER BY T1.Year_working


Question: Show the names of employees that work for companies with sales bigger than 200.

Context: CREATE TABLE employment (People_ID VARCHAR, Company_ID VARCHAR); CREATE TABLE company (Company_ID VARCHAR, Sales_in_Billion INTEGER); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT T2.Name FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID WHERE T3.Sales_in_Billion > 200


Question: Show the names of companies and the number of employees they have

Context: CREATE TABLE company (Name VARCHAR, Company_ID VARCHAR); CREATE TABLE people (People_ID VARCHAR); CREATE TABLE employment (People_ID VARCHAR, Company_ID VARCHAR)

SELECT T3.Name, COUNT(*) FROM employment AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID JOIN company AS T3 ON T1.Company_ID = T3.Company_ID GROUP BY T3.Name


Question: List the names of people that are not employed by any company

Context: CREATE TABLE employment (Name VARCHAR, People_ID VARCHAR); CREATE TABLE people (Name VARCHAR, People_ID VARCHAR)

SELECT Name FROM people WHERE NOT People_ID IN (SELECT People_ID FROM employment)


Question: list the names of the companies with more than 200 sales in the descending order of sales and profits.

Context: CREATE TABLE company (name VARCHAR, Sales_in_Billion INTEGER, Profits_in_Billion VARCHAR)

SELECT name FROM company WHERE Sales_in_Billion > 200 ORDER BY Sales_in_Billion, Profits_in_Billion DESC


Question: How many film are there?

Context: CREATE TABLE film (Id VARCHAR)


Question: List the distinct director of all films.

Context: CREATE TABLE film (Director VARCHAR)


Question: What is the average ticket sales gross in dollars of films?

Context: CREATE TABLE film (Gross_in_dollar INTEGER)


Question: What are the low and high estimates of film markets?

Context: CREATE TABLE film_market_estimation (Low_Estimate VARCHAR, High_Estimate VARCHAR)

SELECT Low_Estimate, High_Estimate FROM film_market_estimation


Question: What are the types of film market estimations in year 1995?

Context: CREATE TABLE film_market_estimation (TYPE VARCHAR, YEAR VARCHAR)

SELECT TYPE FROM film_market_estimation WHERE YEAR = 1995


Question: What are the maximum and minimum number of cities in all markets.

Context: CREATE TABLE market (Number_cities INTEGER)

SELECT MAX(Number_cities), MIN(Number_cities) FROM market


Question: How many markets have number of cities smaller than 300?

SELECT COUNT(*) FROM market WHERE Number_cities < 300


Question: List all countries of markets in ascending alphabetical order.

Context: CREATE TABLE market (Country VARCHAR)

SELECT Country FROM market ORDER BY Country


Question: List all countries of markets in descending order of number of cities.

Context: CREATE TABLE market (Country VARCHAR, Number_cities VARCHAR)

SELECT Country FROM market ORDER BY Number_cities DESC


Question: Please show the titles of films and the types of market estimations.

Context: CREATE TABLE film (Title VARCHAR, Film_ID VARCHAR); CREATE TABLE film_market_estimation (Type VARCHAR, Film_ID VARCHAR)

SELECT T1.Title, T2.Type FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID


Question: Show the distinct director of films with market estimation in the year of 1995.

Context: CREATE TABLE film (Director VARCHAR, Film_ID VARCHAR); CREATE TABLE film_market_estimation (Film_ID VARCHAR, Year VARCHAR)

SELECT DISTINCT T1.Director FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID WHERE T2.Year = 1995


Question: What is the average number of cities of markets with low film market estimate bigger than 10000?

Context: CREATE TABLE market (Number_cities INTEGER, Market_ID VARCHAR); CREATE TABLE film_market_estimation (Market_ID VARCHAR, Low_Estimate INTEGER)

SELECT AVG(T2.Number_cities) FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T1.Low_Estimate > 10000


Question: Please list the countries and years of film market estimations.

Context: CREATE TABLE film_market_estimation (Year VARCHAR, Market_ID VARCHAR); CREATE TABLE market (Country VARCHAR, Market_ID VARCHAR)

SELECT T2.Country, T1.Year FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID


Question: Please list the years of film market estimations when the market is in country "Japan" in descending order.

Context: CREATE TABLE film_market_estimation (Year VARCHAR, Market_ID VARCHAR); CREATE TABLE market (Market_ID VARCHAR, Country VARCHAR)

SELECT T1.Year FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.Market_ID = T2.Market_ID WHERE T2.Country = "Japan" ORDER BY T1.Year DESC


Question: List the studios of each film and the number of films produced by that studio.

Context: CREATE TABLE film (Studio VARCHAR)

SELECT Studio, COUNT(*) FROM film GROUP BY Studio


Question: List the name of film studio that have the most number of films.

Context: CREATE TABLE film (Studio VARCHAR)

SELECT Studio FROM film GROUP BY Studio ORDER BY COUNT(*) DESC LIMIT 1


Question: List the names of studios that have at least two films.

Context: CREATE TABLE film (Studio VARCHAR)

SELECT Studio FROM film GROUP BY Studio HAVING COUNT(*) >= 2


Question: List the title of films that do not have any market estimation.

Context: CREATE TABLE film_market_estimation (Title VARCHAR, Film_ID VARCHAR); CREATE TABLE film (Title VARCHAR, Film_ID VARCHAR)

SELECT Title FROM film WHERE NOT Film_ID IN (SELECT Film_ID FROM film_market_estimation)


Question: Show the studios that have produced films with director "Nicholas Meyer" and "Walter Hill".

Context: CREATE TABLE film (Studio VARCHAR, Director VARCHAR)

SELECT Studio FROM film WHERE Director = "Nicholas Meyer" INTERSECT SELECT Studio FROM film WHERE Director = "Walter Hill"


Question: Find the titles and studios of the films that are produced by some film studios that contained the word "Universal".

Context: CREATE TABLE film (title VARCHAR, Studio VARCHAR)

SELECT title, Studio FROM film WHERE Studio LIKE "%Universal%"


Question: Show the studios that have not produced films with director "Walter Hill".

SELECT Studio FROM film EXCEPT SELECT Studio FROM film WHERE Director = "Walter Hill"


Question: List the studios which average gross is above 4500000.

Context: CREATE TABLE film (Studio VARCHAR, Gross_in_dollar INTEGER)

SELECT Studio FROM film GROUP BY Studio HAVING AVG(Gross_in_dollar) >= 4500000


Question: What is the title of the film that has the highest high market estimation.

Context: CREATE TABLE film_market_estimation (Film_ID VARCHAR); CREATE TABLE film (Film_ID VARCHAR)

SELECT t1.title FROM film AS T1 JOIN film_market_estimation AS T2 ON T1.Film_ID = T2.Film_ID ORDER BY high_estimate DESC LIMIT 1


Question: What are the titles and directors of the films were never presented in China?

Context: CREATE TABLE film (title VARCHAR, director VARCHAR, film_id VARCHAR, country VARCHAR); CREATE TABLE market (Market_ID VARCHAR); CREATE TABLE film_market_estimation (market_id VARCHAR)

SELECT title, director FROM film WHERE NOT film_id IN (SELECT film_id FROM film_market_estimation AS T1 JOIN market AS T2 ON T1.market_id = T2.Market_ID WHERE country = 'China')


Question: How many calendar items do we have?

Context: CREATE TABLE Ref_calendar (Id VARCHAR)


Question: Show all calendar dates and day Numbers.

Context: CREATE TABLE Ref_calendar (calendar_date VARCHAR, day_Number VARCHAR)

SELECT calendar_date, day_Number FROM Ref_calendar


Question: Show the number of document types.

Context: CREATE TABLE Ref_document_types (Id VARCHAR)


Question: List all document type codes and document type names.

Context: CREATE TABLE Ref_document_types (document_type_code VARCHAR, document_type_name VARCHAR)

SELECT document_type_code, document_type_name FROM Ref_document_types


Question: What is the name and description for document type code RV?

Context: CREATE TABLE Ref_document_types (document_type_name VARCHAR, document_type_description VARCHAR, document_type_code VARCHAR)

SELECT document_type_name, document_type_description FROM Ref_document_types WHERE document_type_code = "RV"


Question: What is the document type code for document type "Paper"?

SELECT document_type_code FROM Ref_document_types WHERE document_type_name = "Paper"


Question: Show the number of documents with document type code CV or BK.

Context: CREATE TABLE All_documents (document_type_code VARCHAR)

SELECT COUNT(*) FROM All_documents WHERE document_type_code = "CV" OR document_type_code = "BK"


Question: What is the date when the document "Marry CV" was stored?

Context: CREATE TABLE All_documents (date_stored VARCHAR, Document_name VARCHAR)

SELECT date_stored FROM All_documents WHERE Document_name = "Marry CV"


Question: What is the day Number and date of all the documents?

Context: CREATE TABLE All_documents (Date_Stored VARCHAR, date_stored VARCHAR); CREATE TABLE Ref_calendar (day_Number VARCHAR, calendar_date VARCHAR)

SELECT T2.day_Number, T1.Date_Stored FROM All_documents AS T1 JOIN Ref_calendar AS T2 ON T1.date_stored = T2.calendar_date


Question: What is the document type name for the document with name "How to read a book"?

Context: CREATE TABLE Ref_document_types (document_type_name VARCHAR, document_type_code VARCHAR); CREATE TABLE All_documents (document_type_code VARCHAR, document_name VARCHAR)

SELECT T2.document_type_name FROM All_documents AS T1 JOIN Ref_document_types AS T2 ON T1.document_type_code = T2.document_type_code WHERE T1.document_name = "How to read a book"


Question: Show the number of locations.

Context: CREATE TABLE Ref_locations (Id VARCHAR)


Question: List all location codes and location names.

Context: CREATE TABLE Ref_locations (location_code VARCHAR, location_name VARCHAR)

SELECT location_code, location_name FROM Ref_locations


Question: What are the name and description for location code x?

Context: CREATE TABLE Ref_locations (location_name VARCHAR, location_description VARCHAR, location_code VARCHAR)

SELECT location_name, location_description FROM Ref_locations WHERE location_code = "x"


Question: What is the location code for the country "Canada"?

SELECT location_code FROM Ref_locations WHERE location_name = "Canada"


Question: How many roles are there?

Context: CREATE TABLE ROLES (Id VARCHAR)


Question: List all role codes, role names, and role descriptions.

Context: CREATE TABLE ROLES (role_code VARCHAR, role_name VARCHAR, role_description VARCHAR)

SELECT role_code, role_name, role_description FROM ROLES


Question: What are the name and description for role code "MG"?

Context: CREATE TABLE ROLES (role_name VARCHAR, role_description VARCHAR, role_code VARCHAR)

SELECT role_name, role_description FROM ROLES WHERE role_code = "MG"


Question: Show the description for role name "Proof Reader".

Context: CREATE TABLE ROLES (role_description VARCHAR, role_name VARCHAR)

SELECT role_description FROM ROLES WHERE role_name = "Proof Reader"


Question: Show the name, role code, and date of birth for the employee with name 'Armani'.

Context: CREATE TABLE Employees (employee_name VARCHAR, role_code VARCHAR, date_of_birth VARCHAR, employee_Name VARCHAR)

SELECT employee_name, role_code, date_of_birth FROM Employees WHERE employee_Name = 'Armani'


Question: What is the id for the employee called Ebba?

Context: CREATE TABLE Employees (employee_ID VARCHAR, employee_name VARCHAR)

SELECT employee_ID FROM Employees WHERE employee_name = "Ebba"


Question: Show the names of all the employees with role "HR".

Context: CREATE TABLE Employees (employee_name VARCHAR, role_code VARCHAR)

SELECT employee_name FROM Employees WHERE role_code = "HR"


Question: Show all role codes and the number of employees in each role.

Context: CREATE TABLE Employees (role_code VARCHAR)

SELECT role_code, COUNT(*) FROM Employees GROUP BY role_code


Question: What is the role code with the largest number of employees?

SELECT role_code FROM Employees GROUP BY role_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Show all role codes with at least 3 employees.

SELECT role_code FROM Employees GROUP BY role_code HAVING COUNT(*) >= 3


Question: Show the role code with the least employees.

SELECT role_code FROM Employees GROUP BY role_code ORDER BY COUNT(*) LIMIT 1


Question: What is the role name and role description for employee called Ebba?

Context: CREATE TABLE Employees (role_code VARCHAR, employee_name VARCHAR); CREATE TABLE ROLES (role_name VARCHAR, role_description VARCHAR, role_code VARCHAR)

SELECT T2.role_name, T2.role_description FROM Employees AS T1 JOIN ROLES AS T2 ON T1.role_code = T2.role_code WHERE T1.employee_name = "Ebba"


Question: Show the names of employees with role name Editor.

Context: CREATE TABLE ROLES (role_code VARCHAR, role_name VARCHAR); CREATE TABLE Employees (employee_name VARCHAR, role_code VARCHAR)

SELECT T1.employee_name FROM Employees AS T1 JOIN ROLES AS T2 ON T1.role_code = T2.role_code WHERE T2.role_name = "Editor"


Question: Show the employee ids for all employees with role name "Human Resource" or "Manager".

Context: CREATE TABLE Employees (employee_id VARCHAR, role_code VARCHAR); CREATE TABLE ROLES (role_code VARCHAR, role_name VARCHAR)

SELECT T1.employee_id FROM Employees AS T1 JOIN ROLES AS T2 ON T1.role_code = T2.role_code WHERE T2.role_name = "Human Resource" OR T2.role_name = "Manager"


Question: What are the different location codes for documents?

Context: CREATE TABLE Document_locations (location_code VARCHAR)

SELECT DISTINCT location_code FROM Document_locations


Question: Show the location name for document "Robin CV".

Context: CREATE TABLE Ref_locations (location_name VARCHAR, location_code VARCHAR); CREATE TABLE All_documents (document_id VARCHAR, document_name VARCHAR); CREATE TABLE Document_locations (document_id VARCHAR, location_code VARCHAR)

SELECT T3.location_name FROM All_documents AS T1 JOIN Document_locations AS T2 ON T1.document_id = T2.document_id JOIN Ref_locations AS T3 ON T2.location_code = T3.location_code WHERE T1.document_name = "Robin CV"


Question: Show the location code, the starting date and ending data in that location for all the documents.

Context: CREATE TABLE Document_locations (location_code VARCHAR, date_in_location_from VARCHAR, date_in_locaton_to VARCHAR)

SELECT location_code, date_in_location_from, date_in_locaton_to FROM Document_locations


Question: What is "the date in location from" and "the date in location to" for the document with name "Robin CV"?

Context: CREATE TABLE All_documents (document_id VARCHAR, document_name VARCHAR); CREATE TABLE Document_locations (date_in_location_from VARCHAR, date_in_locaton_to VARCHAR, document_id VARCHAR)

SELECT T1.date_in_location_from, T1.date_in_locaton_to FROM Document_locations AS T1 JOIN All_documents AS T2 ON T1.document_id = T2.document_id WHERE T2.document_name = "Robin CV"


Question: Show the location codes and the number of documents in each location.

SELECT location_code, COUNT(*) FROM Document_locations GROUP BY location_code


Question: What is the location code with the most documents?

SELECT location_code FROM Document_locations GROUP BY location_code ORDER BY COUNT(*) DESC LIMIT 1


Question: Show the location codes with at least 3 documents.

SELECT location_code FROM Document_locations GROUP BY location_code HAVING COUNT(*) >= 3


Question: Show the location name and code with the least documents.

Context: CREATE TABLE Document_locations (location_code VARCHAR); CREATE TABLE Ref_locations (location_name VARCHAR, location_code VARCHAR)

SELECT T2.location_name, T1.location_code FROM Document_locations AS T1 JOIN Ref_locations AS T2 ON T1.location_code = T2.location_code GROUP BY T1.location_code ORDER BY COUNT(*) LIMIT 1


Question: What are the names of the employees who authorised the destruction and the employees who destroyed the corresponding documents?

Context: CREATE TABLE Employees (employee_name VARCHAR, employee_id VARCHAR); CREATE TABLE Documents_to_be_destroyed (Destruction_Authorised_by_Employee_ID VARCHAR, Destroyed_by_Employee_ID VARCHAR)

SELECT T2.employee_name, T3.employee_name FROM Documents_to_be_destroyed AS T1 JOIN Employees AS T2 ON T1.Destruction_Authorised_by_Employee_ID = T2.employee_id JOIN Employees AS T3 ON T1.Destroyed_by_Employee_ID = T3.employee_id


Question: Show the id of each employee and the number of document destruction authorised by that employee.

Context: CREATE TABLE Documents_to_be_destroyed (Destruction_Authorised_by_Employee_ID VARCHAR)

SELECT Destruction_Authorised_by_Employee_ID, COUNT(*) FROM Documents_to_be_destroyed GROUP BY Destruction_Authorised_by_Employee_ID


Question: Show the employee ids and the number of documents destroyed by each employee.

Context: CREATE TABLE Documents_to_be_destroyed (Destroyed_by_Employee_ID VARCHAR)

SELECT Destroyed_by_Employee_ID, COUNT(*) FROM Documents_to_be_destroyed GROUP BY Destroyed_by_Employee_ID


Question: Show the ids of the employees who don't authorize destruction for any document.

Context: CREATE TABLE Documents_to_be_destroyed (employee_id VARCHAR, Destruction_Authorised_by_Employee_ID VARCHAR); CREATE TABLE Employees (employee_id VARCHAR, Destruction_Authorised_by_Employee_ID VARCHAR)

SELECT employee_id FROM Employees EXCEPT SELECT Destruction_Authorised_by_Employee_ID FROM Documents_to_be_destroyed


Question: Show the ids of all employees who have authorized destruction.

SELECT DISTINCT Destruction_Authorised_by_Employee_ID FROM Documents_to_be_destroyed


Question: Show the ids of all employees who have destroyed a document.

SELECT DISTINCT Destroyed_by_Employee_ID FROM Documents_to_be_destroyed


Question: Show the ids of all employees who don't destroy any document.

Context: CREATE TABLE Employees (employee_id VARCHAR, Destroyed_by_Employee_ID VARCHAR); CREATE TABLE Documents_to_be_destroyed (employee_id VARCHAR, Destroyed_by_Employee_ID VARCHAR)

SELECT employee_id FROM Employees EXCEPT SELECT Destroyed_by_Employee_ID FROM Documents_to_be_destroyed


Question: Show the ids of all employees who have either destroyed a document or made an authorization to do this.

Context: CREATE TABLE Documents_to_be_destroyed (Destroyed_by_Employee_ID VARCHAR, Destruction_Authorised_by_Employee_ID VARCHAR)

SELECT Destroyed_by_Employee_ID FROM Documents_to_be_destroyed UNION SELECT Destruction_Authorised_by_Employee_ID FROM Documents_to_be_destroyed


Question: What are the names of all clubs?

Context: CREATE TABLE club (clubname VARCHAR)


Question: How many students are there?

Context: CREATE TABLE student (Id VARCHAR)


Question: What are the first names of all the students?

Context: CREATE TABLE student (fname VARCHAR)


Question: Find the last names of the members of the club "Bootup Baltimore".

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE student (lname VARCHAR, stuid VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR)

SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"


Question: Who are the members of the club named "Hopkins Student Enterprises"? Show the last name.

SELECT t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"


Question: How many members does the club "Tennis Club" has?

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE student (stuid VARCHAR)

SELECT COUNT(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"


Question: Find the number of members of club "Pen and Paper Gaming".

SELECT COUNT(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Pen and Paper Gaming"


Question: How many clubs does "Linda Smith" belong to?

Context: CREATE TABLE student (stuid VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE club (clubid VARCHAR)

SELECT COUNT(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Linda" AND t3.lname = "Smith"


Question: Find the number of clubs where "Tracy Kim" is a member.

SELECT COUNT(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Tracy" AND t3.lname = "Kim"


Question: Find all the female members of club "Bootup Baltimore". Show the first name and last name.

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE student (fname VARCHAR, lname VARCHAR, stuid VARCHAR, sex VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR)

SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.sex = "F"


Question: Find all the male members of club "Hopkins Student Enterprises". Show the first name and last name.

SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t3.sex = "M"


Question: Find all members of "Bootup Baltimore" whose major is "600". Show the first name and last name.

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE student (fname VARCHAR, lname VARCHAR, stuid VARCHAR, major VARCHAR)

SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.major = "600"


Question: Which club has the most members majoring in "600"?

Context: CREATE TABLE student (stuid VARCHAR, major VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE club (clubname VARCHAR, clubid VARCHAR)

SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.major = "600" GROUP BY t1.clubname ORDER BY COUNT(*) DESC LIMIT 1


Question: Find the name of the club that has the most female students.

Context: CREATE TABLE student (stuid VARCHAR, sex VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE club (clubname VARCHAR, clubid VARCHAR)

SELECT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.sex = "F" GROUP BY t1.clubname ORDER BY COUNT(*) DESC LIMIT 1


Question: What is the description of the club named "Tennis Club"?

Context: CREATE TABLE club (clubdesc VARCHAR, clubname VARCHAR)

SELECT clubdesc FROM club WHERE clubname = "Tennis Club"


Question: Find the description of the club "Pen and Paper Gaming".

SELECT clubdesc FROM club WHERE clubname = "Pen and Paper Gaming"


Question: What is the location of the club named "Tennis Club"?

Context: CREATE TABLE club (clublocation VARCHAR, clubname VARCHAR)

SELECT clublocation FROM club WHERE clubname = "Tennis Club"


Question: Find the location of the club "Pen and Paper Gaming".

SELECT clublocation FROM club WHERE clubname = "Pen and Paper Gaming"


Question: Where is the club "Hopkins Student Enterprises" located?

SELECT clublocation FROM club WHERE clubname = "Hopkins Student Enterprises"


Question: Find the name of all the clubs at "AKW".

Context: CREATE TABLE club (clubname VARCHAR, clublocation VARCHAR)

SELECT clubname FROM club WHERE clublocation = "AKW"


Question: How many clubs are located at "HHH"?

Context: CREATE TABLE club (clublocation VARCHAR)

SELECT COUNT(*) FROM club WHERE clublocation = "HHH"


Question: What are the first and last name of the president of the club "Bootup Baltimore"?

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE student (fname VARCHAR, lname VARCHAR, stuid VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR, position VARCHAR)

SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t2.position = "President"


Question: Who is the "CTO" of club "Hopkins Student Enterprises"? Show the first name and last name.

SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t2.position = "CTO"


Question: How many different roles are there in the club "Bootup Baltimore"?

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE member_of_club (position VARCHAR, clubid VARCHAR)

SELECT COUNT(DISTINCT t2.position) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid WHERE t1.clubname = "Bootup Baltimore"


Question: How many members of "Bootup Baltimore" are older than 18?

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE student (stuid VARCHAR, age VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR)

SELECT COUNT(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age > 18


Question: How many members of club "Bootup Baltimore" are younger than 18?

SELECT COUNT(*) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.age < 18


Question: Find the names of all the clubs that have at least a member from the city with city code "BAL".

Context: CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE club (clubname VARCHAR, clubid VARCHAR); CREATE TABLE student (stuid VARCHAR, city_code VARCHAR)

SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "BAL"


Question: Find the names of the clubs that have at least a member from the city with city code "HOU".

SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.city_code = "HOU"


Question: How many clubs does the student named "Eric Tai" belong to?

Context: CREATE TABLE student (stuid VARCHAR, fname VARCHAR, lname VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE club (clubname VARCHAR, clubid VARCHAR)

SELECT COUNT(DISTINCT t1.clubname) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Eric" AND t3.lname = "Tai"


Question: List the clubs having "Davis Steven" as a member.

SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.fname = "Davis" AND t3.lname = "Steven"


Question: List the clubs that have at least a member with advisor "1121".

Context: CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR); CREATE TABLE club (clubname VARCHAR, clubid VARCHAR); CREATE TABLE student (stuid VARCHAR, advisor VARCHAR)

SELECT DISTINCT t1.clubname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t3.advisor = 1121


Question: What is the average age of the members of the club "Bootup Baltimore"?

Context: CREATE TABLE club (clubid VARCHAR, clubname VARCHAR); CREATE TABLE student (age INTEGER, stuid VARCHAR); CREATE TABLE member_of_club (clubid VARCHAR, stuid VARCHAR)

SELECT AVG(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore"


Question: Find the average age of members of the club "Hopkins Student Enterprises".

SELECT AVG(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises"


Question: Retrieve the average age of members of the club "Tennis Club".

SELECT AVG(t3.age) FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Tennis Club"