In SOQL, is it possible to say
LIMIT 1 object1 record FOR EVERY 1 object2 record?
Example) Every Account has Property__c lookup relationship. I want SOQL to return a list of the most upcoming Account (using Account.Arrival_Time__c) FOR EACH property.
So I would like a Query where each Property is only returned ONCE, and returns a SINGLE Account to match. What I have currently, is a SOQL query that returns several upcoming accounts for each Property__c record.
for (Account acc : [SELECT Id, Name, Arrival_Time__c, Property__c FROM Account WHERE Arrival_Time__c >= :Datetime.Now() AND Property__c
IN :listOfProperties ORDER BY Arrival_Time__c ASC])