Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to normalize denormalized results for Excel 1

Status
Not open for further replies.

Jables

Programmer
Aug 28, 2001
148
US
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.
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?
 
Look into crosstab queries in the help file. This will do what you need.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top