Query that returns results from two tables for one employee

J

John

I have two queries that contain the following data, one with employee code -
date worked - and sum of hours worked. The second query has the employee code
- date scheduled - and the schedule code (see example below). I am trying to
write a query that would return one line for the employee code with the
corresponding details of the schedule code and hours worked on the next line.

Query 1:
Emp Date Hours
xxx 08/17/08 9:30
xxy 08/17/08 10:15
xxx 08/18/08 8:15
xxy 08/18/08 12:00
xxx 08/19/08 8:30
xxy 08/19/08 10:00

Query 2:
Emp 08/17/08 08/18/08 08/19/08
xxy WS3 NS3 WS3
xxx NS3 WS3 WS3

I would like Query 3 (new) to return the following:

Emp 08/17/08 08/18/08 08/19/08
xxx NS3 WS3 WS3
xxx 9:30 8:15 8:30
xxy WS3 WS3 WS3
xxy 10:15 12:00 10:00

Any help would be greatly appreciated.

Thanks
John
 
J

Jerry Whittle

Is Query 2 a crosstab query or are there actually dates across the columns in
the table? If you have dates across, that's a problem right there.

The best that I can think of is turning Query 1 into a crosstab query then
joining Query 1 and Query 2 in a Union query. Even then there could be a
bunch of problems, if for example, the queries don't return the same columns.
 
J

John

Jerry

I have converted Query 1 to a crosstab query (sorry for not typing it out
that way) but only so I could mimic the dates across the top to mirror the
schedule details. The schedule code query (Query 2) is an Excel output from a
system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top