You can display totals by using aggregate functions and the GROUP BY clause, or row aggregate functions and the COMPUTE clause.
Aggregate functions ¾ SUM, AVG, COUNT, COUNT(*), MAX, and MIN ¾ generate summary values that appear as new columns in query results. The GROUP BY clause, part of the SELECT statement, divides a table into groups. GROUP BY and aggregate functions are often used together, and a summary value is calculated for each group.
Row aggregate functions ¾ SUM, AVG, COUNT, MAX, and MIN ¾ and the COMPUTE clause are always used together as part of a SELECT statement. Row aggregate functions generate summary values that appear as additional rows in the query results. A SQL statement that includes a COMPUTE clause and row aggregate functions produces a report with detail rows and summary rows.