Aggregate functions in SOQL, such as SUM() and MAX(), allow you to roll up and summarize your data in a query
Aggregate functions become a more powerful tool to generate reports when you use them with a GROUP BY clause. For example, you could find the average Amount for all your opportunities by campaign
AggregateResult[] groupedResults
= [SELECT CampaignId, AVG(Amount)
FROM Opportunity
GROUP BY CampaignId];
for (AggregateResult ar : groupedResults) {
System.debug('Campaign ID' + ar.get('CampaignId'));
System.debug('Average amount' + ar.get('expr0'));
}
Try to down load the pdf and go through the aggregate section I hope all your doubt will clear .
http://www.salesforce.com/us/developer/docs/soql_sosl/salesforce_soql_sosl.pdf
Any issue let me know I will help .
Thanks
Manoj
Aggregate functions become a more powerful tool to generate reports when you use them with a GROUP BY clause. For example, you could find the average Amount for all your opportunities by campaign
List of all fucntion
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_agg_functions.htm
https://www.salesforce.com/developer/docs/api/Content/sforce_api_calls_query_aggregateresult.htm
Please mark this as solution if this will help you