Data aggregation is the process of gathering and expressing data in a summary to get more information about particular groups based on specific conditions. HQL offers several built-in aggregate functions, such as max(...), min(...), and avg(...). It also supports advanced aggregation using keywords such as GROUPING SETS, ROLLUP, and CUBE, and different types of window function.
The basic built-in aggregate functions are usually used with the GROUP BY clause. If there is no GROUP BY clause specified, it aggregates over the whole row (all columns) by default. Besides aggregate functions, all columns selected must also be included in the GROUP BY clause. The following are a few examples involving the built-in aggregate functions:
- Aggregation without GROUP BY columns:
> SELECT
> count(*) as rowcnt1,
> count(1) as rowcnt2 -- same to...