Originally Posted by
June7
I would need sample raw data to figure out the TOP N approach, if it's even doable with your data.
Another approach uses domain aggregate function but not quite the way ranman describes. Unfortunately domain aggs can be slow.
Build a query that joins the tables then build another query:
SELECT * FROM queryname WHERE NoteDate = DMax("NoteDate", "Notes", "ClientID=" & [ClientID]);
Maybe another approach:
Query1
SELECT ClientID, Max(NoteDate) AS MaxDate FROM Notes GROUP BY ClientID;
or maybe
SELECT ClientID, Max(NoteID) AS MaxNote FROM Notes GROUP BY ClientID;
Query2
build query that joins ClientInfo and Notes tables
Query3
join query 1 and query 2 on the ClientID and date (or NoteID) fields (compound join)