+ Start a Discussion
hamza ntwarihamza ntwari 

Sum values of field

Hello,

How do I sum the entered values in a field? I have trid the standard sql sum() but that is not working.
Thanks
Mahesh DMahesh D
Hi Hamza,

Please find the best information about Aggregate functions:

SUM()

Returns the total sum of a numeric field. For example:
SELECT SUM(Amount)
FROM Opportunity
WHERE IsClosed = false AND Probability > 60

Please find the below useful links:

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions.htm

http://blog.jeffdouglas.com/2010/04/12/using-aggregateresult-in-salesforce-com-soql/

http://blog.terrasky.com/blog/useful-soql

http://www.laceysnr.com/aggregate-soql-handy-stuff/

http://www.salesforcegeneral.com/salesforce-articles/using-aggregate-functions-in-soql.html

http://sfdcsrini.blogspot.com/2014/04/what-is-aggregate-functions-in-soql.html


If it is a Master-Detail Relationship and wants to find the Sum of Child record field's then you can use Roll-Up Summary:

https://help.salesforce.com/apex/HTViewHelpDoc?id=fields_about_roll_up_summary_fields.htm&language=en (https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions.htm)


Please do let me know if it helps you.

Regards,
Mahesh