I have a table that tracks the completion of interval tasks. for example, item a has to be completed every 7 days, item b every 1 days, and so on. The table logs the “nextDue” value on insert. I need a query that will return only the latest “nextDue” dates that are within 3 days of becoming due. This is what I have right now:
SELECT items.id, items.shortDescription, recs.nextDue, sup.name
FROM lut_ResponsibleParties sup INNER JOIN(
rec_controlCompletion recs INNER JOIN lut_controlItems items
ON recs.controlItem = items.id)
ON items.responsiblePerson = sup.id
WHERE datediff("d",Now(),recs.nextDue) <= 3
This was close, except it is returning ALL items that are less than or equal to 3 days, even if the latest completion date is beyond that. Does that make sense? I need the query to only return items based on the latest completion date. I don’t know how else to explain that. Please let me know if I can clarify.
i think i figured it out somewhere in this jumbled mess: