Aggregation (subtotals) operations compute a single value from a collection of values using operators such as Sum, Min, Max, Count, etc. The most basic difference between Aggregation operations and Simple operations is that aggregation uses grouping. Aggregation without grouping is also possible but in that case it produces a single row of grand totals. Grouping is needed to produce subtotals. Input rows are grouped by values of one or more columns, and subtotals are calculated for each of those groups.
The following syntax illustrates an aggregation query that calculates subtotals for each products, so the number of resulting row is equal to the number of products. For each product, two subtotals (aggregations) are calculated. These subtotals are number of orders including that product, and maximum discount for that product in those orders.
While using aggregation, you can group more than one column. The following query illustrates this as it has two grouping columns as a result of which there will be more groups in the result.
In the above query results in more than one group each containing orders including a certain product with a certain discount, and the subtotal will show the number of orders in the group.