This may be somewhat of a newbie question, but I'm having a hard time wrapping my head around it. I have a table that contains several columns including: Name, Type, Qty, Response_Time, and Complete_Time. Name is the name of the person, Type is a type of work "unit", Qty is the number of work units of a particular type, and the two time columns are total times (in number of seconds) for each quantity of units.
Name Type Qty Response_Time Complete_Time
Bob A 20 600 800
Bob B 30 700 1000
Bob C 40 800 1200
(There will be more than 3 types of work, but I only need A, B, and C.)
I need to do a calculation to find the average amount of time spent per unit per person, but there's a catch: the numerator of the equation is the sum of the total times of 3 types, but the denominator is the sum of the quantities of only 2 types. So basically:
Sum(Response_Time) Where Type IN (A,B,C)
divided by
Sum(Qty) Where Type IN (A,B)
I know it's an incorrect average, but unfortunately that's the way the boss wants it.
I'm pretty sure I can do this with a cursor, but I wanted to avoid that if possible. Just not sure how else to go about it.
Any suggestions?
TIA,
Jas
Name Type Qty Response_Time Complete_Time
Bob A 20 600 800
Bob B 30 700 1000
Bob C 40 800 1200
(There will be more than 3 types of work, but I only need A, B, and C.)
I need to do a calculation to find the average amount of time spent per unit per person, but there's a catch: the numerator of the equation is the sum of the total times of 3 types, but the denominator is the sum of the quantities of only 2 types. So basically:
Sum(Response_Time) Where Type IN (A,B,C)
divided by
Sum(Qty) Where Type IN (A,B)
I know it's an incorrect average, but unfortunately that's the way the boss wants it.
I'm pretty sure I can do this with a cursor, but I wanted to avoid that if possible. Just not sure how else to go about it.
Any suggestions?
TIA,
Jas