Here is a situation where i need to get the last date of apppointment for a contact and i also need the id of the last appointment date.
All appointments are stored in custom object and has a lookup to contact.
SELECT Max(startDate__c ) FROM appointments Group by contact__c
IS there a way to get id of the appointment for which the max(startDate__c) is returned? I want to have for each contact which is the latest appointment date and the id of the latest appointment.