human
Schema:
classroom (building, room_number, capacity)
department (dept_name, building, budget)
course (course_id, title, dept_name, credits)
instructor (ID, name, dept_name, salary)
section (course_id, sec_id, semester, year, building, room_number, time_slot_id)
teaches (ID, course_id, sec_id, semester, year)
student (ID, name, dept_name, tot_cred)
takes (ID, course_id, sec_id, semester, year, grade)
advisor (s_ID, i_ID)
time_slot (time_slot_id, day, start_hr, start_min, end_hr, end_min)
prereq (course_id, prereq_id)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the semester and year which has the least number of student taking any class.
assistant
SELECT semester , YEAR FROM takes GROUP BY semester , YEAR ORDER BY count(*) LIMIT 1
human
Find the name of department has the highest amount of students?
assistant
SELECT dept_name FROM student GROUP BY dept_name ORDER BY count(*) DESC LIMIT 1
human
How many rooms whose capacity is less than 50 does the Lamberton building have?
assistant
SELECT count(*) FROM classroom WHERE building = 'Lamberton' AND capacity < 50
human
Find the total number of students in each department.
assistant
SELECT count(*) , dept_name FROM student GROUP BY dept_name
human
Count the number of rooms that are not in the Lamberton building.
assistant
SELECT count(*) FROM classroom WHERE building != 'Lamberton'
human
Count the number of classrooms in Lamberton.
assistant
SELECT COUNT( * ) FROM classroom WHERE building = "Lamberton" ;