You need to sign in to do that
Don't have an account?
admin Affinity
Subquery Complex
Hi I'm trying to create a client list with, the most recent order, associated but I don't know do the condition between those entities. I need to reference in the second query the first table.
tb02.AccountId = tb01.Account.Id
thanks all
regards
SELECT ..., tb01.Account.Id, ..., ( SELECT tb02.DAT_Real_Delivery_Date__c FROM Order tb02 WHERE tb02.AccountId = tb01.Account.Id AND tb02.CHK_Collection__c = false AND tb02.Status = 'Sent' AND tb02.DAT_Real_Delivery_Date__c > TODAY ORDER BY tb02.DAT_Real_Delivery_Date__c DESC NULLS LAST LIMIT 1 ) DAT_Real_Delivery_Date FROM Event tb01 WHERE Type IN ('Off Route','Call') AND tb01.ActivityDate <= today AND (tb01.Activity_Status__c != 'Completed' AND tb01.Activity_Status__c != 'Cancelled') AND (tb01.OwnerId =: userId OR tb01.OwnerId =: otherUserId) AND tb01.IsRecurrence = false AND tb01.AccountId != null ORDER BY tb01.Account.PCK_Customer_Status__c ASC, tb01.ActivityDateTime ASC LIMIT 200How can I do this assignment?
tb02.AccountId = tb01.Account.Id
thanks all
regards
You can go for formula field which returns Boolean on Order object, if possible:
Say a formula field EqualAccountId__c = (AccountId == Event.AccountId)
Then alter the query like
Cardinality is n n n
It is not a direct relationship but through the entity account