Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. Department Employees(by department) Male(By department) Female(by department)
  2. Employee 11 6 5
  3. Management 10 5 5
  4. Owner 1 1 0
  5.  
  6. SELECT [tbDepartment].[DepartmentName] AS [Department name],
  7. Count(*) AS [Number of employees by department type],
  8. (Select Count([EmployeeGender]) FROM [tbEmployee] WHERE [EmployeeGender] = 'Male' AND [DepartmentName] = [tbDepartment].[DepartmentName]) AS [Number of male employees by department type],
  9. (Select Count([EmployeeGender]) FROM [tbEmployee] WHERE [EmployeeGender] = 'Female' AND [DepartmentName] = [tbDepartment].[DepartmentName]) AS [Number of female employees by department type]
  10. FROM [tbEmployee] JOIN [tbDepartment]
  11. ON [tbEmployee].[DepartmentId] = [tbDepartment].[DepartmentId]
  12. GROUP BY [tbDepartment].[DepartmentName];
  13.  
  14. Department Employees(by department) Male(By department) Female(by department)
  15. Employee 11 12 10
  16. Management 10 12 10
  17. Owner 1 12 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement