I have a query in MySQL that returns three columns, a Candidate’s ID, the date they were contacted, and by whom. I’m trying to write a query that ONLY returns the most recent time they were contacted, along with their ID and by whom.
SELECT e.ID,
ByWho,
Date
FROM ContactSummaries e
JOIN(SELECT ID,
MAX(Date) AS LastContact
FROM ContactSummaries
GROUP BY
ID) lu
ON (e.ID = lu.ID AND e.Date = lu.LastContact)
So, that right there works perfectly in SQL Server Management Studio. When I paste it into Access to make a nice little Report, it complains about an “Incomplete query clause”.
Then I tried this:
SELECT
ID,
ByWhom,
Date
FROM( ContactSummaries AS [e]
INNER JOIN
SELECT ID,
MAX(Date) AS LastContacted,
ByWhom
FROM ContactSummaries
ON
ID,
MAX(Date) AS LastContacted,
FROM ContactSummaries
GROUP BY ID)
AS [l]
ON
[e].ID = [l].ID,
AND [e].Date = [l].LastContacted;
“Join expression not supported”. I don’t know SQL (or Access especially) well enough to see what I’m doing wrong, it seems to match their examples on Microsoft’s website.
You cannot use Join by itself in Access. Note also that Date is a reserved word. I think you want