Combining Two Queries

J

JudyB

I have two queries that both give me the information I am looking for.

1. Current Dept Query which has the following fields and tells me each
employee's current Department:
EmpId LastName First Name DeptName
34 Jones Tom Accounting
34 Brown Larry Accounting

35 Smith John Purchasing


and

2. Weeks Service by Department which has these fields and tells me the
number of weeks an employee has spent in each Department:
EmpId DeptName WksService
34 Accounting 417
34 Admin 209
35 Accounting 135
35 Admin 156
35 F/S 52
36 Accounting 4

I am trying to create a query that combines these two queries and will give
me the number of weeks each employee has spent in his/her current Department.
For example: (34) Tom Jones is currently working in the Accounting
Department and has a total of 417 weeks in that Department.

I have be unsuccessful in getting the information tied together. Can anyone
tell me if this is possible and how to get it done? I want to be able to run
reports by Department showing each employeee's service time. Thanks in
advance. Any help is much appreciated.
 
M

Marshall Barton

JudyB said:
I have two queries that both give me the information I am looking for.

1. Current Dept Query which has the following fields and tells me each
employee's current Department:
EmpId LastName First Name DeptName
34 Jones Tom Accounting
34 Brown Larry Accounting

35 Smith John Purchasing


and

2. Weeks Service by Department which has these fields and tells me the
number of weeks an employee has spent in each Department:
EmpId DeptName WksService
34 Accounting 417
34 Admin 209
35 Accounting 135
35 Admin 156
35 F/S 52
36 Accounting 4

I am trying to create a query that combines these two queries and will give
me the number of weeks each employee has spent in his/her current Department.
For example: (34) Tom Jones is currently working in the Accounting
Department and has a total of 417 weeks in that Department.


Does this do what you want?

SELECT D.*, W.WksService
FROM [Current Dept Query] As D
INNER JOIN [Weeks Service by Department] As W
ON D.EmpId = W.EmpId
AND D.DeptName = W.DeptName
 

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