database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
hospital_1
SELECT name FROM department GROUP BY departmentID ORDER BY count(departmentID) DESC LIMIT 1;
Find the department with the most employees.
hospital_1
SELECT head FROM department GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;
Tell me the employee id of the head of the department with the least employees.
hospital_1
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;
Find the name and position of the head of the department with the least employees.
hospital_1
SELECT name FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn
List the names of patients who have made appointments.
hospital_1
SELECT name , phone FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn GROUP BY T1.patient HAVING count(*) > 1
Which patients made more than one appointment? Tell me the name and phone number of these patients.
hospital_1
SELECT appointmentid FROM appointment ORDER BY START DESC LIMIT 1
What is the id of the appointment that started most recently?
hospital_1
SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID
What are the names of all the physicians who took appointments.
hospital_1
SELECT name FROM physician EXCEPT SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID
Which physicians have never taken any appointment? Find their names.
hospital_1
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
What are the name and primarily affiliated department name of each physician?
hospital_1
SELECT T1.name FROM patient AS T1 JOIN appointment AS T2 WHERE T1.ssn = T2.patient ORDER BY T2.start DESC LIMIT 1
Find the name of the patient who made the appointment with the most recent start date.
hospital_1
SELECT count(patient) FROM stay WHERE room = 112
Count the number of patients who stayed in room 112.
hospital_1
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"
Find the number of patients' prescriptions physician John Dorian made.
hospital_1
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
What is the name of the medication used for the patient staying in room 111?
hospital_1
SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1
What is the id of the patient who stayed in room 111 most recently?
hospital_1
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
Find the name of the nurse who has the largest number of appointments.
hospital_1
SELECT T1.name , count(*) FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid
Return the name of each physician and the number of patients he or she treats.
hospital_1
SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING count(*) > 1
Which physicians are in charge of more than one patient? Give me their names.
hospital_1
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
How many rooms does each block floor have?
hospital_1
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
How many rooms are located for each block code?
hospital_1
SELECT DISTINCT blockcode FROM room WHERE unavailable = 0
Tell me the distinct block codes where some rooms are available.
hospital_1
SELECT count(DISTINCT roomtype) FROM room
Find the number of distinct room types available.
hospital_1
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"
List the names of all the physicians who prescribe Thesisin as medication.
hospital_1
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"
Which physicians prescribe a medication of brand X? Tell me the name and position of those physicians.
hospital_1
SELECT count(*) , T1.name FROM medication AS T1 JOIN prescribes AS T2 ON T1.code = T2.medication GROUP BY T1.brand
How many medications are prescribed for each brand?
hospital_1
SELECT name FROM physician WHERE POSITION LIKE '%senior%'
What are the names of the physicians who have 'senior' in their titles.
hospital_1
SELECT patient FROM undergoes ORDER BY dateundergoes LIMIT 1
Which patient is undergoing the most recent treatment?
hospital_1
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
What are the names of patients who are staying in room 111 and have an undergoing treatment?
hospital_1
SELECT DISTINCT name FROM nurse ORDER BY name
What is the alphabetically ordered list of all the distinct names of nurses?
hospital_1
SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN nurse AS T2 ON T1.AssistingNurse = T2.EmployeeID
Which nurses are in charge of patients undergoing treatments?
hospital_1
SELECT DISTINCT name FROM medication ORDER BY name
What is the alphabetically ordered list of all distinct medications?
hospital_1
SELECT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician ORDER BY T2.dose DESC LIMIT 1
Find the physician who prescribed the highest dose. What is his or her name?
hospital_1
SELECT DISTINCT T2.name FROM affiliated_with AS T1 JOIN department AS T2 ON T1.department = T2.departmentid WHERE PrimaryAffiliation = 1
What are the names of departments that have primarily affiliated physicians.
game_1
SELECT count(*) FROM Video_games
How many video games do you have?
game_1
SELECT count(DISTINCT gtype) FROM Video_games
What is the count of different game types?
game_1
SELECT DISTINCT gtype FROM Video_games
What are the different types of video games?
game_1
SELECT gname , gtype FROM Video_games ORDER BY gname
What are the names of all the video games and their types in alphabetical order?
game_1
SELECT gname FROM Video_games WHERE gtype = "Collectible card game"
What are the names of all video games that are collectible cards?
game_1
SELECT gtype FROM Video_games WHERE gname = "Call of Destiny"
What type of game is Call of Destiny?
game_1
SELECT count(*) FROM Video_games WHERE gtype = "Massively multiplayer online game"
Count the number of video games with Massively multiplayer online game type .
game_1
SELECT gtype , count(*) FROM Video_games GROUP BY gtype
What are the types of video games and how many are in each type?
game_1
SELECT gtype FROM Video_games GROUP BY gtype ORDER BY count(*) DESC LIMIT 1
What type has the most games?
game_1
SELECT gtype FROM Video_games GROUP BY gtype ORDER BY count(*) LIMIT 1
What is the type with the fewest games?
game_1
SELECT StuID FROM Student WHERE city_code = "CHI"
What are the ids of all students who live in CHI?
game_1
SELECT StuID FROM Student WHERE Advisor = 1121
What are the ids of all students who have advisor number 1121?
game_1
SELECT Fname FROM Student WHERE Major = 600
What are the first names for all students who are from the major numbered 600?
game_1
SELECT major , avg(age) , min(age) , max(age) FROM Student GROUP BY major
What are the average, minimum, and max ages for each of the different majors?
game_1
SELECT advisor FROM Student GROUP BY advisor HAVING count(*) >= 2
What are the advisors
game_1
SELECT count(DISTINCT sportname) FROM Sportsinfo
How many different types of sports do we offer?
game_1
SELECT count(DISTINCT StuID) FROM Sportsinfo
How many different students are involved in sports?
game_1
SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
What are the ids for all sporty students who are on scholarship?
game_1
SELECT T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.onscholarship = 'Y'
What are the last names for all scholarship students?
game_1
SELECT sum(gamesplayed) FROM Sportsinfo
What is the total number of games played?
game_1
SELECT sum(gamesplayed) FROM Sportsinfo WHERE sportname = "Football" AND onscholarship = 'Y'
What is the total number of all football games played by scholarship students?
game_1
SELECT sportname , count(*) FROM Sportsinfo GROUP BY sportname
How many students play each sport?
game_1
SELECT StuID , count(*) , sum(gamesplayed) FROM Sportsinfo GROUP BY StuID
What are the ids of all students along with how many sports and games did they play?
game_1
SELECT StuID FROM Sportsinfo GROUP BY StuID HAVING sum(hoursperweek) > 10
What are the student IDs for everybody who worked for more than 10 hours per week on all sports?
game_1
SELECT T2.Fname , T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID GROUP BY T1.StuID ORDER BY count(*) DESC LIMIT 1
What is the first and last name of the student who played the most sports?
game_1
SELECT sportname FROM Sportsinfo WHERE onscholarship = 'Y' GROUP BY sportname ORDER BY count(*) DESC LIMIT 1
What is the sport with the most scholarship students?
game_1
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Sportsinfo
What are the ids of all students who don't play sports?
game_1
SELECT StuID FROM Student WHERE major = 600 INTERSECT SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y'
What are the student ids for those on scholarship in major number 600?
game_1
SELECT StuID FROM Student WHERE sex = 'F' INTERSECT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
What are the ids of all female students who play football?
game_1
SELECT StuID FROM Student WHERE sex = 'M' EXCEPT SELECT StuID FROM Sportsinfo WHERE sportname = "Football"
What are the ids of all male students who do not play football?
game_1
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.Fname = "David" AND T2.Lname = "Shieber"
What is the total number of hours per work and number of games played by David Shieber?
game_1
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
What is the total number of hours per week and number of games played by students under 20?
game_1
SELECT count(DISTINCT StuID) FROM Plays_games
How many different students play games?
game_1
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
What are the ids of all students who are not video game players?
game_1
SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games
What are the ids of all students who played video games and sports?
game_1
SELECT gameid , sum(hours_played) FROM Plays_games GROUP BY gameid
What are ids and total number of hours played for each game?
game_1
SELECT Stuid , sum(hours_played) FROM Plays_games GROUP BY Stuid
What are the ids of all students and number of hours played?
game_1
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid ORDER BY sum(hours_played) DESC LIMIT 1
What is the name of the game that has been played the most?
game_1
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid HAVING sum(hours_played) >= 1000
What are the names of all the games that have been played for at least 1000 hours?
game_1
SELECT Gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid JOIN Student AS T3 ON T3.Stuid = T1.Stuid WHERE T3.Lname = "Smith" AND T3.Fname = "Linda"
What are the names of all games played by Linda Smith?
game_1
SELECT T2.lname , T2.fname FROM SportsInfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.SportName = "Football" OR T1.SportName = "Lacrosse"
What is the first and last name of all students who play Football or Lacrosse?
game_1
SELECT fname , age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = "Football" INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = "Lacrosse")
What are the first names and ages of all students who are playing both Football and Lacrosse?
college_2
SELECT DISTINCT building FROM classroom WHERE capacity > 50
What are the distinct buildings with capacities of greater than 50?
college_2
SELECT count(*) FROM classroom WHERE building ! = 'Lamberton'
How many classrooms are not in Lamberton?
college_2
SELECT dept_name , building FROM department WHERE budget > (SELECT avg(budget) FROM department)
Give the name and building of the departments with greater than average budget.
college_2
SELECT building , room_number FROM classroom WHERE capacity BETWEEN 50 AND 100
What are the room numbers and corresponding buildings for classrooms which can seat between 50 to 100 students?
college_2
SELECT dept_name , building FROM department ORDER BY budget DESC LIMIT 1
What is the department name and corresponding building for the department with the greatest budget?
college_2
SELECT name FROM student WHERE dept_name = 'History' ORDER BY tot_cred DESC LIMIT 1
Give the name of the student in the History department with the most credits.
college_2
SELECT count(*) FROM classroom WHERE building = 'Lamberton'
Count the number of classrooms in Lamberton.
college_2
SELECT count(DISTINCT s_id) FROM advisor
Count the number of students who have advisors.
college_2
SELECT count(DISTINCT dept_name) FROM course
Count the number of departments which offer courses.
college_2
SELECT count(DISTINCT course_id) FROM course WHERE dept_name = 'Physics'
Count the number of courses in the Physics department.
college_2
SELECT T1.title FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING count(*) = 2
What are the titles for courses with two prerequisites?
college_2
SELECT T1.title , T1.credits , T1.dept_name FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING count(*) > 1
What is the title, credit value, and department name for courses with more than one prerequisite?
college_2
SELECT count(*) FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)
Count the number of courses without prerequisites.
college_2
SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)
What are the titles of courses without prerequisites?
college_2
SELECT COUNT (DISTINCT id) FROM teaches
Count the number of distinct instructors who have taught a course.
college_2
SELECT sum(budget) FROM department WHERE dept_name = 'Marketing' OR dept_name = 'Finance'
What is the sum of budgets of the Marketing and Finance departments?
college_2
SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%'
What is the name of the department with an instructure who has a name like 'Soisalon'?
college_2
SELECT count(*) FROM classroom WHERE building = 'Lamberton' AND capacity < 50
Count the number of rooms in Lamberton with capacity lower than 50.
college_2
SELECT dept_name , budget FROM department WHERE budget > (SELECT avg(budget) FROM department)
What are the names and budgets of departments with budgets greater than the average?
college_2
SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary LIMIT 1
Give the name of the lowest earning instructor in the Statistics department.
college_2
SELECT title FROM course WHERE dept_name = 'Statistics' INTERSECT SELECT title FROM course WHERE dept_name = 'Psychology'
What is the title of a course that is listed in both the Statistics and Psychology departments?
college_2
SELECT title FROM course WHERE dept_name = 'Statistics' EXCEPT SELECT title FROM course WHERE dept_name = 'Psychology'
What are the titles of courses that are in the Statistics department but not the Psychology department?
college_2
SELECT id FROM teaches WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT id FROM teaches WHERE semester = 'Spring' AND YEAR = 2010
What are the ids of instructors who taught in the Fall of 2009 but not in the Spring of 2010?
college_2
SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id = T2.id WHERE YEAR = 2009 OR YEAR = 2010
What are the names of the students who took classes in 2009 or 2010?
college_2
SELECT dept_name FROM course GROUP BY dept_name ORDER BY count(*) DESC LIMIT 3
What are the names of the 3 departments with the most courses?
college_2
SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1
What is the name of the department with the most credits?

@InProceedings{Yu&al.19, title = {SParC: Cross-Domain Semantic Parsing in Context}, author = {Tao Yu and Rui Zhang and Michihiro Yasunaga and Yi Chern Tan and Xi Victoria Lin and Suyi Li and Heyang Er, Irene Li and Bo Pang and Tao Chen and Emily Ji and Shreya Dixit and David Proctor and Sungrok Shim and Jonathan Kraft, Vincent Zhang and Caiming Xiong and Richard Socher and Dragomir Radev}, booktitle = {Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics}, year = {2019}, address = {Florence, Italy}, publisher = {Association for Computational Linguistics} }

@inproceedings{Yu&al.18c, title = {Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task}, author = {Tao Yu and Rui Zhang and Kai Yang and Michihiro Yasunaga and Dongxu Wang and Zifan Li and James Ma and Irene Li and Qingning Yao and Shanelle Roman and Zilin Zhang and Dragomir Radev} booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing", address = "Brussels, Belgium", publisher = "Association for Computational Linguistics", year = 2018 }

Reference links

SParC task link: https://yale-lily.github.io/sparc SParC Github page: https://github.com/taoyds/sparc Spider task link: https://yale-lily.github.io/spider Spider Github page: https://github.com/taoyds/spider

Downloads last month
21
Edit dataset card