I am trying to return the Task that has a note linked to it with the most recent timestamp. Although this query works, it's not returning the most recent timestamp consistently. Is there another method to doing this?
SELECT DISTINCT tasks.TaskID, tasks.desc, tasks.startdate, tasks.active, notes.note, max(notes.NoteDate)
FROM tasks INNER JOIN notes ON tasks.TaskID=notes.NoteID
WHERE notes.NoteDate >= curdate()
GROUP BY tasks.TaskID