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 name of the department that offers the highest total credits?
assistant
SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1
human
Find the name and budget of departments whose budgets are more than the average budget.
assistant
SELECT dept_name , budget FROM department WHERE budget > (SELECT avg(budget) FROM department)
human
List the names and buildings of all departments sorted by the budget from large to small.
assistant
SELECT dept_name , building FROM department ORDER BY budget DESC
human
Find the name and building of the department with the highest budget.
assistant
SELECT dept_name , building FROM department ORDER BY budget DESC LIMIT 1
human
What is the name and building of the departments whose budget is more than the average budget?
assistant
SELECT dept_name , building FROM department WHERE budget > (SELECT avg(budget) FROM department)
human
Which department has the lowest budget?
assistant
SELECT dept_name FROM department ORDER BY budget LIMIT 1 ;