Database: college_2

Question: How many students and instructors are in each department?
SQL: 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

Question: What are the names of students who have taken the prerequisite for the course International Finance?
SQL: 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')

Question: What are the names and salaries for instructors who earn less than the average salary of instructors in the Physics department?
SQL: SELECT name ,  salary FROM instructor WHERE salary  <  (SELECT avg(salary) FROM instructor WHERE dept_name  =  'Physics')

Question: What are the names of students who have taken Statistics courses?
SQL: 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'

Question: What are the building, room number, semester and year of courses in the Psychology department, sorted using course title?
SQL: 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

Question: What are the names of all instructors in the Comp. Sci. department?
SQL: SELECT name FROM instructor WHERE dept_name  =  'Comp. Sci.'

Question: What are the names of the instructors in the Comp. Sci. department who earn more than 80000?
SQL: SELECT name FROM instructor WHERE dept_name  =  'Comp. Sci.'  AND salary  >  80000

Question: What are the names of all instructors who have taught a course, as well as the corresponding course id?
SQL: SELECT name ,  course_id FROM instructor AS T1 JOIN teaches AS T2 ON T1.ID  =  T2.ID

Question: What are the names of Art instructors who have taught a course, and the corresponding course id?
SQL: SELECT name ,  course_id FROM instructor AS T1 JOIN teaches AS T2 ON T1.ID  =  T2.ID WHERE T1.dept_name  =  'Art'

Question: What are the names of all instructors with names that include "dar"?
SQL: SELECT name FROM instructor WHERE name LIKE '%dar%'

Question: List the distinct names of the instructors, ordered by name.
SQL: SELECT DISTINCT name FROM  instructor ORDER BY name

Question: What are the ids for courses in the Fall of 2009 or the Spring of 2010?
SQL: SELECT course_id FROM SECTION WHERE semester  =  'Fall' AND YEAR  =  2009 UNION SELECT course_id FROM SECTION WHERE semester  =  'Spring' AND YEAR  =  2010

Question: What are the ids for courses that were offered in both Fall of 2009 and Spring of 2010?
SQL: SELECT course_id FROM SECTION WHERE semester  =  'Fall' AND YEAR  =  2009 INTERSECT SELECT course_id FROM SECTION WHERE semester  =  'Spring' AND YEAR  =  2010