0

Here's the three tables I'm working with:

enter image description here

This is the SQL statement I'm working with:

SELECT DISTINCT Employees.Corps_ID, Employees.Last_Name, Employees.First_Name, Employees.Home_Phone, Employees.Mobile_Phone
FROM Shifts INNER JOIN (Employees INNER JOIN Employees_Shifts ON Employees.Employee_ID = Employees_Shifts.Employee_ID) ON Shifts.Shift_ID = Employees_Shifts.Shift_ID
WHERE Shifts.Start_Date_Time Between #11/1/2015# And #12/1/2015# And  Employees_Shifts.Employee_ID = NULL ;

What I really need this query to do is examine all the Shifts over the date range indicated and return only those Employee records that don't match up.

I've tried changing the INNER operator to LEFT in a couple places but Access just keeps complaining and won't run the query. I definitely need some help with this one. Please advise.

1 Answer 1

1
SELECT Employees.Corps_ID, Employees.Last_Name, Employees.First_Name, Employees.Home_Phone, Employees.Mobile_Phone
FROM Employees 
WHERE NOT EXISTS(
    SELECT * from Employees_Shifts 
    JOIN Shifts ON Shifts.Shift_ID = Employees_Shifts.Shift_ID
    WHERE Shifts.Start_Date_Time Between #11/1/2015# And #12/1/2015# 
    AND Employees_Shifts.Employee_ID = Employees.Employee_ID
    )

Btw DISTINCT often indicate some problem with schema or query, always ask why You need it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.