Thursday 25 April 2013


Aggregate SOQL Queries

SOQL statements that summarize or group records are called aggregate queries. Rather
than selecting a set of records and performing calculations on them in Apex, SOQL
allows you to do this within the database.This results in much better performance and
simpler code.This section covers three aspects of aggregate SOQL queries:

. Aggregate Functions: Rather than simply returning the discrete values of a database
field in a SELECT statement, aggregate functions such as SUM apply a simple
calculation on each record and return the accumulated result.

. Grouping Records: The GROUP BY syntax works with aggregate functions to
return a set of summarized results based on common values.

. Grouping Records with Subtotals: SOQL provides two special forms of the
GROUP BY syntax to calculate subtotals and return them in the query results.

No comments:

Post a Comment