Database: college_2

Question: What are the greatest and average capacity for rooms in each building?
SQL: SELECT max(capacity) ,  avg(capacity) ,  building FROM classroom GROUP BY building

Question: What are the titles of courses that are offered in more than one department?
SQL: SELECT title FROM course GROUP BY title HAVING count(*)  >  1

Question: How many total credits are offered by each department?
SQL: SELECT sum(credits) ,  dept_name FROM course GROUP BY dept_name

Question: What is the lowest salary in departments with average salary greater than the overall average.
SQL: SELECT min(salary) ,  dept_name FROM instructor GROUP BY dept_name HAVING avg(salary)  >  (SELECT avg(salary) FROM instructor)

Question: How many courses are provided in each semester and year?
SQL: SELECT count(*) ,  semester ,  YEAR FROM SECTION GROUP BY semester ,  YEAR

Question: Which year had the greatest number of courses?
SQL: SELECT YEAR FROM SECTION GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1

Question: What is the year and semester with the most courses?
SQL: SELECT semester ,  YEAR FROM SECTION GROUP BY semester ,  YEAR ORDER BY count(*) DESC LIMIT 1

Question: What is the name of the deparment with the highest enrollment?
SQL: SELECT dept_name FROM student GROUP BY dept_name ORDER BY count(*) DESC LIMIT 1

Question: How many students are in each department?
SQL: SELECT count(*) ,  dept_name FROM student GROUP BY dept_name

Question: Which semeseter and year had the fewest students?
SQL: SELECT semester ,  YEAR FROM takes GROUP BY semester ,  YEAR ORDER BY count(*) LIMIT 1

Question: Give id of the instructor who advises students in the History department.
SQL: SELECT i_id FROM advisor AS T1 JOIN student AS T2 ON T1.s_id  =  T2.id WHERE T2.dept_name  =  'History'

Question: What are the names and salaries of instructors who advises students in the History department?
SQL: 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'

Question: What are the ids of courses without prerequisites?
SQL: SELECT course_id FROM course EXCEPT SELECT course_id FROM prereq

Question: What are the names of courses without prerequisites?
SQL: SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)

Question: Give the title of the prerequisite to the course International Finance.
SQL: 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')

Question: What is the title of the course with Differential Geometry as a prerequisite?
SQL: 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')

Question: What are the names of students who took a course in the Fall of 2003?
SQL: SELECT name FROM student WHERE id IN (SELECT id FROM takes WHERE semester  =  'Fall' AND YEAR  =  2003)