I have a field called purchase price in orders table. When I query for those orders, I got 4 records. They are as follows

enter image description here

Here, as per the above query, when i sum purchase_price__c, i am getting 194.99. But, when I update the query to return the sum(purchase_price__c), I am getting the result as 216.

enter image description here

Is this issue due to sum function or if we sum the field, will it consider deleted records as well? I'm pretty confused here. Why do the numbers differ?

  • what does count(purchase_price__c) return? – kurunve Aug 13 '19 at 11:50
  • Do you have multi-currency enabled? – Adrian Larson Aug 13 '19 at 11:55
  • No @AdrianLarson. We do not have multi currency enabled – Skumar Aug 13 '19 at 12:00
  • Count(Purchase_Price__c) is returning 4 records @kurunve – Skumar Aug 13 '19 at 12:00
  • You could check the deleted records hypothesis. Do you have any? – Adrian Larson Aug 13 '19 at 12:43

Notice the Deleted and archived records: Include in top right?


enter image description here


enter image description here

  • Thanks @Salesforce-sas. That was set to exclude when I was querying and that means it didnt include deleted records...I'm wondering why the sum is more when when compared to individual records. Please suggest – Skumar Aug 13 '19 at 13:54
  • :). pls mark solved if solved – salesforce-sas Aug 13 '19 at 13:58
  • I wish it would but it didnt @Salesforcesas. I'm getting the same no.of records with deleted records included and excluded. – Skumar Aug 13 '19 at 14:00
  • can u verify in salesforce developer console? – salesforce-sas Aug 13 '19 at 14:05
  • I did @Salesforcesas. I am getting the same total as workbench. – Skumar Aug 13 '19 at 14:10

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.