Last year I posted this question and I got a breakdown of completed surveys by manager.
This year I would like to expand this slightly by introducing JobBand which is in the StaffLookup table. I would like to be able to say WHERE JobBand = 'MNGR' and it would show each of the staff who have a job band of MNGR and a percentage of staff underneath them who have completed the survey against the total number of staff.
Please can I have some pointers on how I would do this?
Edit:
StaffLookup table:
UserSrn | UserName | ManagerSrn | JobBand
=========================================
ABC1 | Jerome | NULL | HEAD
ABC2 | Joe | ABC1 | MNGR
ABC3 | Paul | ABC2 | MNGR
ABC4 | Jack | ABC3 | A
ABC5 | Daniel | ABC3 | A
ABC6 | David | ABC2 | B
ABC7 | Ian | ABC6 | C
ABC8 | Helen | ABC6 | C
SurveyResponses table:
UserSrn | QuestionId | ResponseScore
====================================
ABC2 | 1 | 5
ABC2 | 3 | 4
ABC4 | 24 | 0
ABC3 | 24 | 0
What I would like to see:
UserName | JobBand | Completed | Total | Completed/Total
========================================================
Joe | MNGR | 2 | 4 | 50%
Paul | MNGR | 2 | 2 | 100%
Completed is a 1 when there is a QuestionID of 24. Total is just 1 for each user. I hope this makes sense. Let me know if more detail is required.
asked
May 25 '11 at 12:13 AM
in Default
Ian Roke
1.7k
●
24
●
29
●
31
As always Ian - can we have some sample data + table structures please? The other question had a few revisions of these and I wouldnt want to pick the wrong one(s)...!
+1 @Fatherjack
@Ian - you're no longer a "newbie" here at ASK, please help us to help you, thanks :)
Sorry I had to rush I was expected in a meeting. Going to update the question now @Fatherjack @WilliamD
I don't see how the expected output matches to your sample data.
The way I understand it, you count the number of entries where QuestionId = 24 for each subordinate of a manager (JobBand='MNGR') and include the manager in the calculation too.
If so, then your expected output for the test data supplied would be:
Am I right, or have I misunderstood?
No the manager isn't included in their results but in the next tier in the structure up however I am not interested in anything above MNGR because that is the manager of the MNGR tier. Does that make sense?