Query Duplicate Records & Dates

G

Guest

Hi,

I have a table of employees' history of start and term dates. Start and
Term Dates constantly changes so there will be several records attached to
the employee. I need to create a query listing the current employee who is
working and another one listing employees who are no longer on assignment.

How do I extract just the most recent dates and ensure that there are no
duplicate names in both list?

Version: Access 2003, Professional

Appreciate the help, Thanks!
 
P

Pieter Wijnen

A starter would be

SELECT E.EMPLOYEEID, -1 AS OCCUPIED FROM EMP E
WHERE E.START >= DATE() AND E.TERM <= DATE()
UNION ALL
SELECT E.EMPLOYEEID,0 FROM EMP E
WHERE NOT EXISTS (SELECT 'X' FROM EMP AS E2
WHERE E2.EMPLOYEEID= E2.EMPLOYEEID AND START >= DATE() AND E2.TERM <=
DATE())

HTH

Pieter
 
P

Pieter Wijnen

A starter would be

SELECT E.EMPLOYEEID, -1 AS OCCUPIED FROM EMP E
WHERE E.START >= DATE() AND E.TERM <= DATE()
UNION ALL
SELECT E.EMPLOYEEID,0 FROM EMP E
WHERE NOT EXISTS (SELECT 'X' FROM EMP AS E2
WHERE E2.EMPLOYEEID= E2.EMPLOYEEID AND START >= DATE() AND E2.TERM <=
DATE())

HTH

Pieter

sgyvln said:
Hi,

I have a table of employees' history of start and term dates. Start and
Term Dates constantly changes so there will be several records attached to
the employee. I need to create a query listing the current employee who
is
working and another one listing employees who are no longer on assignment.

How do I extract just the most recent dates and ensure that there are no
duplicate names in both list?

Version: Access 2003, Professional

Appreciate the help, Thanks!



--
 

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

Similar Threads


Top