SELECT TOP (100) PERCENT dbo.department.name, COUNT(dbo.Nurses.id) AS Expr1, dbo.Degrees.name AS Expr2, CASE dbo.Nurses.jobstatus WHEN 'FT' THEN 0.90 WHEN 'PT' THEN 0.60 WHEN 'PRN' THEN 0.30 END AS Status FROM dbo.department INNER JOIN dbo.Nurses ON dbo.department.id = dbo.Nurses.dept_id INNER JOIN dbo.Users ON dbo.Nurses.user_id = dbo.Users.id INNER JOIN dbo.Degrees ON dbo.Nurses.Degree_ID = dbo.Degrees.id GROUP BY dbo.department.name, dbo.Degrees.name, dbo.Nurses.jobstatus ORDER BY dbo.department.name
The above Query will list each department, then the total number of nurses for that department by degree. So:
Unit 1 has a total of 24 nurses and it breaks down in the query like this:
Unit 1 3 Bachelors
Unit 1 1 Associates
Unit 1 20 No Degree
Similar to the above is the output. The case statement takes the job status which is a text value, and based on those values it will convert them to a decimal value. The problem I'm having is I need a new column that takes the total nurses column and totals it by those job status values. So:
Let's say for the first row 2 of the nurses are .9 and 1 is .6
Unit 1 3 Bachelors 2.4
My issue is in the query, how am I supposed to read the column value that contains the number of nurses and in the same row, total those values?
Thank you.