Get the Rank of employee with more working hours:
SELECT
DimEmployee.Firstname, DimDepartment.DepartmentName, SUM(DurationInHours) As Total,ROW_NUMBER() OVER (ORDER BY DimEmployee.Firstname) AS 'Row Number',RANK() OVER (ORDER BY DimDepartment.DepartmentName) AS 'Rank_Dep',RANK() OVER (ORDER BY SUM(DurationInHours) DESC) AS 'Rank_Emp'FROM FactTimetrackJOIN DimEmployee on DimEmployee.Employeekey = FactTimetrack.EmployeeKeyJOIN DimDepartment ON DimDepartment.DepartmentKey = Dimemployee.DepartmentKeyGROUP BY DimEmployee.Firstname, DimDepartment.DepartmentNameORDER
BY SUM(DurationInHours) DESC,DimEmployee.Firstname
SELECT
DimEmployee.Firstname, DimDepartment.DepartmentName, SUM(DurationInHours) As Total,ROW_NUMBER() OVER (ORDER BY DimEmployee.Firstname) AS 'Row Number',RANK() OVER (ORDER BY DimDepartment.DepartmentName) AS 'Rank_Dep',RANK() OVER (ORDER BY SUM(DurationInHours) DESC) AS 'Rank_Emp'FROM FactTimetrackJOIN DimEmployee on DimEmployee.Employeekey = FactTimetrack.EmployeeKeyJOIN DimDepartment ON DimDepartment.DepartmentKey = Dimemployee.DepartmentKeyGROUP BY DimEmployee.Firstname, DimDepartment.DepartmentNameORDER
BY SUM(DurationInHours) DESC,DimEmployee.Firstname
No comments:
Post a Comment