2

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
LIMIT 50

Please help Thanks

2 Answers 2

1

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

1

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
LIMIT 50

Regards

2
  • 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
    Commented Dec 20, 2017 at 9:59
  • deleted i was wrong in my comment
    – Torsen
    Commented Dec 20, 2017 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .