Query to Return Most Recent Date (1 Viewer)

Princecoxy

New member
Local time
Today, 09:02
Joined
May 29, 2022
Messages
1
Hello All, I seem to be stuck on this query. A Customer can have multiple Interaction dates and Next Appointments which can have multiple entries by Date. I am trying to query the most recent Date for each NextAppointment per Customer.

So, looking at the below sample I would want to return 13-Mar-22 for that particular Customer and 21-Jul-22 for Customer with identification number 1234. These rows contain the most recent Date per NextAppointment.

Any thoughts on how I can accomplish this? Thanks.
 

Attachments

  • Screenshot 2022-05-29 104948.jpg
    Screenshot 2022-05-29 104948.jpg
    42.6 KB · Views: 160

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:02
Joined
Feb 19, 2002
Messages
43,257
If there are multiple interaction types, you might need criteria to specify which type.

SELECT CustomerID, Max(InteractionDate) AS MDate FROM table GROUP BY CustomerID
Where CustomerID = Forms!myform!myCustomerID AND InteractionType = "NextAppointment";
 

June7

AWF VIP
Local time
Yesterday, 23:02
Joined
Mar 9, 2014
Messages
5,470
WHERE clause comes before GROUP BY.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 03:02
Joined
Feb 19, 2002
Messages
43,257
Thanks for the correction. I wasn't paying attention.
 

Users who are viewing this thread

Top Bottom