Last post Apr 13, 2020 07:59 PM by Kulrom
Apr 13, 2020 06:11 PM|Markus33|LINK
Can someone help me independently solve this solution so that i will have a strong understanding of how to interpret the following testing question. The question itself seems more untypical than the actual resulting output. I am only near junior status
in SQL queries. Please help! Markus.
Given two tables, Employee and Department, generate a summary of how many employees are in each
department. Each department should be listed, whether they currently have any employees or not. The
results should be sorted from high to low by number of employees, and then alphabetically by department
when departments have the same number of employees The results should list the department name followed by the employee count.
Apr 13, 2020 07:59 PM|Kulrom|LINK
I am not quite sure that it will help you to learn what you study but here we go
SELECT * FROM
D.Name AS DepartmentName, COUNT(E.Id) OVER(PARTITION BY E.Department_ID) AS EmployeesNumber
Department AS D
Employee AS E
D.Id = E.Department_ID
) AS Dept