Is this possible to use one subquery to query for two child records, one the latest from the past and the earliest from the future? If so, how to do it?
If I try to run this query
select id, name,
(select Id, Name, DateTimeField__c from Children__r WHERE DateTimeField__c <= TODAY ORDER BY DateTimeField__c DESC LIMIT 1 ) ,
(select Id, Name, DateTimeField__c from Children__r WHERE DateTimeField__c >= TODAY ORDER BY DateTimeField__c ASC LIMIT 1 )
from Parent__c where id in ( select Parend__c from Child__c )
I receive error
Cannot follow the same aggregate relationship twice: Children__r