the below query works but it does'nt what I'm expecting and the problem with the below query is that it gives me all the record where as; what I want is to get the minimum dob with Id.
here is my apex code:
List<AggregateResult> aggregateResults = [SELECT id, min(dob__c) dob from myobject__c WHERE Id IN :setIds group by id];
for (AggregateResult ar : aggregateResults) {
System.debug(ar.get('dob'));
System.debug(ar.get('id'));
}
Should need to re-write in a different way to get the Id & minimum date of birth?
max(dob__c)
in your query as well? The record that contains the min value is not necessarily the same record that contains the max value.