I'm beyond stuck with some SQL questions on my Bsc. CS revision exam paper - I know you all dislike answering academic questions but this is my last resort (and revision for Monday's exam) and I have no idea how to go about it.
I have 2 tables:
Department (deptId: string, deptName: string, managerId: string)
Employee (empId: string, empName: string, jobName: string, salary: integer, deptId: string)
and 2 queries I need to run:
1) Display the name and the id of the department that has the largest number of employees
2) Display the names of the departments whose employees' average salary is at least 40000
I believe I need to use join
and having
here but those are things I can't quite wrap my big head around.
So my question is, how would I write these queries? I don't need an answer, per se, but an explanatory method to know how to achieve the objective. Again, this is not academic work but revision for a final exam.