Database: college_2

Question: Give the name of the lowest earning instructor in the Statistics department.
SQL: SELECT name FROM instructor WHERE dept_name  =  'Statistics' ORDER BY salary LIMIT 1

Question: What is the title of a course that is listed in both the Statistics and Psychology departments?
SQL: SELECT title FROM course WHERE dept_name  =  'Statistics' INTERSECT SELECT title FROM course WHERE dept_name  =  'Psychology'

Question: What are the titles of courses that are in the Statistics department but not the Psychology department?
SQL: SELECT title FROM course WHERE dept_name  =  'Statistics' EXCEPT SELECT title FROM course WHERE dept_name  =  'Psychology'

Question: What are the ids of instructors who taught in the Fall of 2009 but not in the Spring of 2010?
SQL: SELECT id FROM teaches WHERE semester  =  'Fall' AND YEAR  =  2009 EXCEPT SELECT id FROM teaches WHERE semester  =  'Spring' AND YEAR  =  2010

Question: What are the names of the students who took classes in 2009 or 2010?
SQL: SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id  =  T2.id WHERE YEAR  =  2009 OR YEAR  =  2010

Question: What are the names of the 3 departments with the most courses?
SQL: SELECT dept_name FROM course GROUP BY dept_name ORDER BY count(*) DESC LIMIT 3

Question: What is the name of the department with the most credits?
SQL: SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1

Question: Given the titles of all courses, in order of titles and credits.
SQL: SELECT title FROM course ORDER BY title ,  credits

Question: Give the name of the department with the lowest budget.
SQL: SELECT dept_name FROM department ORDER BY budget LIMIT 1

Question: What are the names and buildings of the deparments, sorted by budget descending?
SQL: SELECT dept_name ,  building FROM department ORDER BY budget DESC

Question: Give the name of the highest paid instructor.
SQL: SELECT name FROM instructor ORDER BY salary DESC LIMIT 1

Question: Give all information regarding instructors, in order of salary from least to greatest.
SQL: SELECT * FROM instructor ORDER BY salary

Question: What are the names of students and their respective departments, ordered by number of credits from least to greatest?
SQL: SELECT name ,  dept_name FROM student ORDER BY tot_cred

Question: Show all titles and their instructors' names for courses in 2008, in alphabetical order by title.
SQL: 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

Question: What are the names of instructors who advise more than one student?
SQL: 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

Question: What are the names of students who have more than one advisor?
SQL: 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

Question: How many rooms in each building have a capacity of over 50?
SQL: SELECT count(*) ,  building FROM classroom WHERE capacity  >  50 GROUP BY building