Database: college_2

Question: What are the distinct buildings with capacities of greater than 50?
SQL: SELECT DISTINCT building FROM classroom WHERE capacity  >  50

Question: How many classrooms are not in Lamberton?
SQL: SELECT count(*) FROM classroom WHERE building ! =  'Lamberton'

Question: Give the name and building of the departments with greater than average budget.
SQL: SELECT dept_name ,  building FROM department WHERE budget  >  (SELECT avg(budget) FROM department)

Question: What are the room numbers and corresponding buildings for classrooms which can seat between 50 to 100 students?
SQL: SELECT building ,  room_number FROM classroom WHERE capacity BETWEEN 50 AND 100

Question: What is the department name and corresponding building for the department with the greatest budget?
SQL: SELECT dept_name ,  building FROM department ORDER BY budget DESC LIMIT 1

Question: Give the name of the student in the History department with the most credits.
SQL: SELECT name FROM student WHERE dept_name  =  'History' ORDER BY tot_cred DESC LIMIT 1

Question: Count the number of classrooms in Lamberton.
SQL: SELECT count(*) FROM classroom WHERE building  =  'Lamberton'

Question: Count the number of students who have advisors.
SQL: SELECT count(DISTINCT s_id) FROM advisor

Question: Count the number of departments which offer courses.
SQL: SELECT count(DISTINCT dept_name) FROM course

Question: Count the number of courses in the Physics department.
SQL: SELECT count(DISTINCT course_id) FROM course WHERE dept_name  =  'Physics'

Question: What are the titles for courses with two prerequisites?
SQL: 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

Question: What is the title, credit value, and department name for courses with more than one prerequisite?
SQL: 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

Question: Count the number of courses without prerequisites.
SQL: SELECT count(*) FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)

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

Question: Count the number of distinct instructors who have taught a course.
SQL: SELECT COUNT (DISTINCT id) FROM teaches

Question: What is the sum of budgets of the Marketing and Finance departments?
SQL: SELECT sum(budget) FROM department WHERE dept_name  =  'Marketing' OR dept_name  =  'Finance'

Question: What is the name of the department with an instructure who has a name like 'Soisalon'?
SQL: SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%'

Question: Count the number of rooms in Lamberton with capacity lower than 50.
SQL: SELECT count(*) FROM classroom WHERE building  =  'Lamberton' AND capacity  <  50

Question: What are the names and budgets of departments with budgets greater than the average?
SQL: SELECT dept_name ,  budget FROM department WHERE budget  >  (SELECT avg(budget) FROM department)