database_id
stringlengths
4
31
query
stringlengths
22
577
question
stringlengths
19
224
college_2
SELECT title FROM course ORDER BY title , credits
Given the titles of all courses, in order of titles and credits.
college_2
SELECT dept_name FROM department ORDER BY budget LIMIT 1
Give the name of the department with the lowest budget.
college_2
SELECT dept_name , building FROM department ORDER BY budget DESC
What are the names and buildings of the deparments, sorted by budget descending?
college_2
SELECT name FROM instructor ORDER BY salary DESC LIMIT 1
Give the name of the highest paid instructor.
college_2
SELECT * FROM instructor ORDER BY salary
Give all information regarding instructors, in order of salary from least to greatest.
college_2
SELECT name , dept_name FROM student ORDER BY tot_cred
What are the names of students and their respective departments, ordered by number of credits from least to greatest?
college_2
SELECT T1.title , T3.name FROM course AS T1 JOIN teaches AS T2 ON T1.course_id = T2.course_id JOIN instructor AS T3 ON T2.id = T3.id WHERE YEAR = 2008 ORDER BY T1.title
Show all titles and their instructors' names for courses in 2008, in alphabetical order by title.
college_2
SELECT T1.name FROM instructor AS T1 JOIN advisor AS T2 ON T1.id = T2.i_id GROUP BY T2.i_id HAVING count(*) > 1
What are the names of instructors who advise more than one student?
college_2
SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id = T2.s_id GROUP BY T2.s_id HAVING count(*) > 1
What are the names of students who have more than one advisor?
college_2
SELECT count(*) , building FROM classroom WHERE capacity > 50 GROUP BY building
How many rooms in each building have a capacity of over 50?
college_2
SELECT max(capacity) , avg(capacity) , building FROM classroom GROUP BY building
What are the greatest and average capacity for rooms in each building?
college_2
SELECT title FROM course GROUP BY title HAVING count(*) > 1
What are the titles of courses that are offered in more than one department?
college_2
SELECT sum(credits) , dept_name FROM course GROUP BY dept_name
How many total credits are offered by each department?
college_2
SELECT min(salary) , dept_name FROM instructor GROUP BY dept_name HAVING avg(salary) > (SELECT avg(salary) FROM instructor)
What is the lowest salary in departments with average salary greater than the overall average.
college_2
SELECT count(*) , semester , YEAR FROM SECTION GROUP BY semester , YEAR
How many courses are provided in each semester and year?
college_2
SELECT YEAR FROM SECTION GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
Which year had the greatest number of courses?
college_2
SELECT semester , YEAR FROM SECTION GROUP BY semester , YEAR ORDER BY count(*) DESC LIMIT 1
What is the year and semester with the most courses?
college_2
SELECT dept_name FROM student GROUP BY dept_name ORDER BY count(*) DESC LIMIT 1
What is the name of the deparment with the highest enrollment?
college_2
SELECT count(*) , dept_name FROM student GROUP BY dept_name
How many students are in each department?
college_2
SELECT semester , YEAR FROM takes GROUP BY semester , YEAR ORDER BY count(*) LIMIT 1
Which semeseter and year had the fewest students?
college_2
SELECT i_id FROM advisor AS T1 JOIN student AS T2 ON T1.s_id = T2.id WHERE T2.dept_name = 'History'
Give id of the instructor who advises students in the History department.
college_2
SELECT T2.name , T2.salary FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'History'
What are the names and salaries of instructors who advises students in the History department?
college_2
SELECT course_id FROM course EXCEPT SELECT course_id FROM prereq
What are the ids of courses without prerequisites?
college_2
SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)
What are the names of courses without prerequisites?
college_2
SELECT title FROM course WHERE course_id IN (SELECT T1.prereq_id FROM prereq AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.title = 'International Finance')
Give the title of the prerequisite to the course International Finance.
college_2
SELECT title FROM course WHERE course_id IN (SELECT T1.course_id FROM prereq AS T1 JOIN course AS T2 ON T1.prereq_id = T2.course_id WHERE T2.title = 'Differential Geometry')
What is the title of the course with Differential Geometry as a prerequisite?
college_2
SELECT name FROM student WHERE id IN (SELECT id FROM takes WHERE semester = 'Fall' AND YEAR = 2003)
What are the names of students who took a course in the Fall of 2003?
college_2
SELECT T1.title FROM course AS T1 JOIN SECTION AS T2 ON T1.course_id = T2.course_id WHERE building = 'Chandler' AND semester = 'Fall' AND YEAR = 2010
Give the title of the course offered in Chandler during the Fall of 2010.
college_2
SELECT T1.name FROM instructor AS T1 JOIN teaches AS T2 ON T1.id = T2.id JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T3.title = 'C Programming'
What are the names of instructors who have taught C Programming courses?
college_2
SELECT T2.name , T2.salary FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'Math'
What are the names and salaries of instructors who advise students in the Math department?
college_2
SELECT T2.name FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id WHERE T3.dept_name = 'Math' ORDER BY T3.tot_cred
What are the names of all instructors who advise students in the math depart sorted by total credits of the student.
college_2
SELECT title FROM course WHERE course_id IN (SELECT T1.prereq_id FROM prereq AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.title = 'Mobile Computing')
What is the title of the course that is a prerequisite for Mobile Computing?
college_2
SELECT T2.name FROM advisor AS T1 JOIN instructor AS T2 ON T1.i_id = T2.id JOIN student AS T3 ON T1.s_id = T3.id ORDER BY T3.tot_cred DESC LIMIT 1
What is the name of the instructor who advises the student with the greatest number of total credits?
college_2
SELECT name FROM instructor WHERE id NOT IN (SELECT id FROM teaches)
What are the names of instructors who didn't teach?
college_2
SELECT id FROM instructor EXCEPT SELECT id FROM teaches
What are the ids of instructors who didnt' teach?
college_2
SELECT name FROM instructor WHERE id NOT IN (SELECT id FROM teaches WHERE semester = 'Spring')
What are the names of instructors who didn't teach courses in the Spring?
college_2
SELECT dept_name FROM instructor GROUP BY dept_name ORDER BY avg(salary) DESC LIMIT 1
Which department has the highest average instructor salary?
college_2
SELECT avg(T1.salary) , count(*) FROM instructor AS T1 JOIN department AS T2 ON T1.dept_name = T2.dept_name ORDER BY T2.budget DESC LIMIT 1
How many instructors are in the department with the highest budget, and what is their average salary?
college_2
SELECT T3.title , T3.credits FROM classroom AS T1 JOIN SECTION AS T2 ON T1.building = T2.building AND T1.room_number = T2.room_number JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.capacity = (SELECT max(capacity) FROM classroom)
Give the title and credits for the course that is taught in the classroom with the greatest capacity.
college_2
SELECT name FROM student WHERE id NOT IN (SELECT T1.id FROM takes AS T1 JOIN course AS T2 ON T1.course_id = T2.course_id WHERE T2.dept_name = 'Biology')
What are the names of students who haven't taken any Biology courses?
college_2
SELECT count(DISTINCT T2.id) , count(DISTINCT T3.id) , T3.dept_name FROM department AS T1 JOIN student AS T2 ON T1.dept_name = T2.dept_name JOIN instructor AS T3 ON T1.dept_name = T3.dept_name GROUP BY T3.dept_name
How many students and instructors are in each department?
college_2
SELECT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id = T2.id WHERE T2.course_id IN (SELECT T4.prereq_id FROM course AS T3 JOIN prereq AS T4 ON T3.course_id = T4.course_id WHERE T3.title = 'International Finance')
What are the names of students who have taken the prerequisite for the course International Finance?
college_2
SELECT name , salary FROM instructor WHERE salary < (SELECT avg(salary) FROM instructor WHERE dept_name = 'Physics')
What are the names and salaries for instructors who earn less than the average salary of instructors in the Physics department?
college_2
SELECT T3.name FROM course AS T1 JOIN takes AS T2 ON T1.course_id = T2.course_id JOIN student AS T3 ON T2.id = T3.id WHERE T1.dept_name = 'Statistics'
What are the names of students who have taken Statistics courses?
college_2
SELECT T2.building , T2.room_number , T2.semester , T2.year FROM course AS T1 JOIN SECTION AS T2 ON T1.course_id = T2.course_id WHERE T1.dept_name = 'Psychology' ORDER BY T1.title
What are the building, room number, semester and year of courses in the Psychology department, sorted using course title?
college_2
SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.'
What are the names of all instructors in the Comp. Sci. department?
college_2
SELECT name FROM instructor WHERE dept_name = 'Comp. Sci.' AND salary > 80000
What are the names of the instructors in the Comp. Sci. department who earn more than 80000?
college_2
SELECT name , course_id FROM instructor AS T1 JOIN teaches AS T2 ON T1.ID = T2.ID
What are the names of all instructors who have taught a course, as well as the corresponding course id?
college_2
SELECT name , course_id FROM instructor AS T1 JOIN teaches AS T2 ON T1.ID = T2.ID WHERE T1.dept_name = 'Art'
What are the names of Art instructors who have taught a course, and the corresponding course id?
college_2
SELECT name FROM instructor WHERE name LIKE '%dar%'
What are the names of all instructors with names that include "dar"?
college_2
SELECT DISTINCT name FROM instructor ORDER BY name
List the distinct names of the instructors, ordered by name.
college_2
SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 UNION SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010
What are the ids for courses in the Fall of 2009 or the Spring of 2010?
college_2
SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 INTERSECT SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010
What are the ids for courses that were offered in both Fall of 2009 and Spring of 2010?
college_2
SELECT course_id FROM SECTION WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT course_id FROM SECTION WHERE semester = 'Spring' AND YEAR = 2010
What are the ids of courses offered in Fall of 2009 but not in Spring of 2010?
college_2
SELECT DISTINCT salary FROM instructor WHERE salary < (SELECT max(salary) FROM instructor)
What are the distinct salaries of all instructors who earned less than the maximum salary?
college_2
SELECT COUNT (DISTINCT ID) FROM teaches WHERE semester = 'Spring' AND YEAR = 2010
How many instructors teach a course in the Spring of 2010?
college_2
SELECT dept_name , AVG (salary) FROM instructor GROUP BY dept_name HAVING AVG (salary) > 42000
What are the names and average salaries for departments with average salary higher than 42000?
college_2
SELECT name FROM instructor WHERE salary > (SELECT min(salary) FROM instructor WHERE dept_name = 'Biology')
What are the names of instructors who earn more than at least one instructor from the Biology department?
college_2
SELECT name FROM instructor WHERE salary > (SELECT max(salary) FROM instructor WHERE dept_name = 'Biology')
What are the names of all instructors with a higher salary than any of the instructors in the Biology department?
college_1
SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting"
How many professors are in the accounting dept?
college_1
SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211"
How many professors teach a class with the code ACCT-211?
college_1
SELECT T3.EMP_FNAME , T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = "Biology"
What are the first and last name of all biology professors?
college_1
SELECT DISTINCT T1.EMP_FNAME , T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = "ACCT-211"
What are the first names and birthdates of the professors in charge of ACCT-211?
college_1
SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski'
How many classes does the professor whose last name is Graztevski teach?
college_1
SELECT school_code FROM department WHERE dept_name = "Accounting"
What is the school code of the accounting department?
college_1
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220'
What is the description for the CIS-220 and how many credits does it have?
college_1
SELECT dept_address FROM department WHERE dept_name = 'History'
Where is the history department?
college_1
SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS'
What are the different locations of the school with the code BUS?
college_1
SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code
Count different addresses of each school.
college_1
SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261'
What is the course description and number of credits for QM-261?
college_1
SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code
How many departments are in each school?
college_1
SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5
How many different departments are there in each school that has less than 5 apartments?
college_1
SELECT count(*) , crs_code FROM CLASS GROUP BY crs_code
How many sections does each course have?
college_1
SELECT sum(crs_credit) , dept_code FROM course GROUP BY dept_code
How many credits does the department offer?
college_1
SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2
For each classroom with at least 2 classes, how many classes are offered?
college_1
SELECT count(*) , dept_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code GROUP BY dept_code
How many classes are held in each department?
college_1
SELECT count(*) , T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code
How many classes exist for each school?
college_1
SELECT count(*) , T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code
How many different professors are there for the different schools?
college_1
SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1
What is the count and code of the job with the most employee?
college_1
SELECT T1.school_code FROM department AS T1 JOIN professor AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.school_code ORDER BY count(*) LIMIT 1
Which school has the fewest professors?
college_1
SELECT count(*) , dept_code FROM professor WHERE prof_high_degree = 'Ph.D.' GROUP BY dept_code
How many professors have a Ph.D. in each department?
college_1
SELECT count(*) , dept_code FROM student GROUP BY dept_code
How many students are in each department?
college_1
SELECT sum(stu_hrs) , dept_code FROM student GROUP BY dept_code
How many hours do the students spend studying in each department?
college_1
SELECT max(stu_gpa) , avg(stu_gpa) , min(stu_gpa) , dept_code FROM student GROUP BY dept_code
What is the highest, lowest, and average student GPA for every department?
college_1
SELECT T2.dept_name , avg(T1.stu_gpa) FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY avg(T1.stu_gpa) DESC LIMIT 1
Which department has the highest average student GPA, and what is the average gpa?
college_1
SELECT count(DISTINCT school_code) FROM department
How many schools are there in the department?
college_1
SELECT count(DISTINCT class_code) FROM CLASS
How many unique classes are offered?
college_1
SELECT count(DISTINCT crs_code) FROM CLASS
What are the number of different course codes?
college_1
SELECT count(DISTINCT dept_name) FROM department
How many different departments are there?
college_1
SELECT count(*) FROM department AS T1 JOIN course AS T2 ON T1.dept_code = T2.dept_code WHERE dept_name = "Computer Info. Systems"
How many courses does the department of Computer Information Systmes offer?
college_1
SELECT count(DISTINCT class_section) FROM CLASS WHERE crs_code = 'ACCT-211'
What is the number of different class sections offered in the course ACCT-211?
college_1
SELECT sum(T1.crs_credit) , T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code
What are the total number of credits offered by each department?
college_1
SELECT T3.dept_name FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T1.dept_code = T3.dept_code GROUP BY T1.dept_code ORDER BY sum(T1.crs_credit) DESC LIMIT 1
Which department offers the most credits all together?
college_1
SELECT count(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code WHERE T1.crs_code = 'ACCT-211'
What are the total number of students enrolled in ACCT-211?
college_1
SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'
What are the first names of all students in course ACCT-211?
college_1
SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211' AND T2.enroll_grade = 'C'
What are the first names of all students who took ACCT-211 and received a C?
college_1
SELECT count(*) FROM employee
How many employees are there all together?
college_1
SELECT count(*) FROM professor WHERE prof_high_degree = 'Ph.D.'
What is the total number of professors with a Ph.D. ?
college_1
SELECT count(*) FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code WHERE T4.dept_name = 'Accounting'
How many students are enrolled in some classes that are taught by an accounting professor?
college_1
SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY count(*) DESC LIMIT 1
What is the name of the department with the most students enrolled?