In the object Asset we have a custom lookup field called License__C and in License__C there's a custom lookup field called Account__C

i want to receive the amount of assets, per license, per account. Something like that: enter image description here

the number of assets is determined in the field Quantity.

i have no idea how to do this, i tried this first but i know its not even near the answer:

select License__r.Account__c, sum(Quantity) 
from Asset 
group by License__r.Account__c

Please help Thanks


select Id, License__c,License__r.Account__c acc, sum(Quantity) from Asset GROUP BY ROLLUP (Id ,License__c,License__r.Account__c) Please try this one and let me know.You should always use alias for related fields. Thanks

| improve this answer | |

I think that you need to group by account and license, and after that count the id of assets

Try this query:

select License__c,License__r.Account__c, sum(Quantity)  
from Asset 
group by License__r.Account__c,License__c


| improve this answer | |
  • Thanks for the response! however, i edited the question, i need to sum of quantity. i tried your query and changed the count(id) but haven't received anything – Dana Griff Dec 20 '17 at 9:59
  • deleted i was wrong in my comment – Torsen Dec 20 '17 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.