I have a query that is pulling timesheet records. It calculates the total hours spent (elapsedtime) per each employee, per job. It returns results like this.
I need a SQL query that looks will return results that look like this:
Okay, so the formatting above is a bit messy, but the idea is that I need each employee's summarized hours on the same row with it's associated job. Are subqueries the answer here?
Code:
jobno jobname empl elapsedtime
221 xjob1x Clay 6
221 xjob1x Jim 3.75
221 xjob1x Steve 0.5
103 xjob2x Jim 71
103 xjob2x Steve 26.5
103 xjob2x Tim 54
200.07 xjob3x Jim 0.75
200.07 xjob3x Tim 2.5
231.02 xjob4x Clay 0.5
231.02 xjob4x Jason 101.5
231.02 xjob4x Jim 6.5
231.02 xjob4x Steve 35.25
239.01 xjob5x Clay 5.5
239.01 xjob5x Jim 0.5
242 xjob6x Jim 3.75
243 xjob7x Jim 6.75
243 xjob7x Tim 10
246 xjob8x Clay 9
246 xjob8x Jim 2
I need a SQL query that looks will return results that look like this:
Code:
jobno jobname clay jason jim tim steve
221 xjob1x 6 0 3.75 0 0.5
103 xjob2x 0 0 71 54 0
200.07 xjob3x 0 0 0.75 2.5 0
231.02 xjob4x 0.5 101.5 6.5 0 35.25
239.02 xjob5x 5.5 0 0.5 0 0
242 xjob6x 0 0 3.75 0 0
243 xjob7x 0 0 6.75 10 0
Okay, so the formatting above is a bit messy, but the idea is that I need each employee's summarized hours on the same row with it's associated job. Are subqueries the answer here?