I need to find the max date of 2 field on Object__c
Structure
Object_A is parent
Object__B is junction object where Object__A and Object__C are lookup fields
Object__c is object that has the date fields where I need to find the max value of 2 fields.
There may be multiple Object__C records.
When an Object__C is update I query for the Object__B record where the Object__C record is housed and then query all of the Object__C records. I think I have this part ok. My question is how do I get all of the Object__C records into an Aggregate query and find the max date of the 2 fields? I will be pushing the dates to Object__A. Or is using an Aggregate query the incorrect approach?
List<AggregateResult> permitAggrDateList = [
SELECT Id, MAX(Rec_Date_c), MAX(Submit_Date__c)
FROM Object__C
WHERE Id IN : ?????
GROUP BY Id
ORDER BY MAX(Rec_Date__c), MAX(Submit_Date__c) DESC
];