Question : Query showing Last Results only

I have a list of Calls made to clients (fields include CallDate, primary key CallID, ClientID and System). Some clients have multiple calls made to them. I want to run a query showing only the last call made to each client (Query: LastCall).

If I run a query returning only the ClientID field and the Max value of CallDate, I get the last call date for each client (Query: Last Call - Min Detail). However, if I add to this query the fields CallID and System, the query returns all calls made, not just the last calls (Query: Last Call - All Details).

How do I return all the fields (Call ID, Call Date, ClientID, System) but only for the Last Call made to each Client?

See File attached (Table: Calls, Query: Last Call - Min Detail & Last Call - All Details)

Answer : Query showing Last Results only

Kitten,

The code that pcelba displays works well if you don't need to edit any of the fields showing in the select statement.  Actually it will generally run considerably quicker than the following method, but  if you need to be able to edit the results, you will need to use something like:

1:
2:
3:
4:
SELECT Calls.ClientID, Calls.CallID, Calls.System, Calls.CallDate
FROM Calls
WHERE Calls.CallDate = (SELECT Max(T.CallDate) FROM Calls as T
                        WHERE T.ClientID = Calls.ClientID)
Random Solutions  
 
programming4us programming4us