Design Assistance

G

Guest

I have been given a request that I am in a quandary as to how to proceed.
Mgmt has asked for a list of all employees who have perfect attendance by
week and month. I have an Attendance table that shows when the person is off
and an interval week calendar. But I only want people who do not have an
entry in the Attendance table for a week. Ideas?
 
D

Douglas J. Steele

SELECT ID, EmployeeName FROM Employees
WHERE ID NOT IN (SELECT ID FROM Absences)
ORDER BY EmployeeName

or

SELECT Employees.ID, Employees.EmployeeName
FROM Employees LEFT JOIN Absences
ON Employees.ID = Absences.ID
WHERE Absences.ID IS NULL
ORDER BY EmployeesEmployeeName
 
P

Pieter Wijnen

or normally the fastest method:

SELECT ID, EmployeeName FROM Employees
WHERE NOT EXISTS (SELECT 'X' FROM Absences WHERE Absences.ID=Employees.ID)
ORDER BY EmployeeName

Pieter
 

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