Red Hat Training

A Red Hat training course is available for Red Hat JBoss Web Server

14.8. Aggregate Functions

HQL queries can even return the results of aggregate functions on properties:
select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)
from Cat cat
The supported aggregate functions are:
  • avg(...), sum(...), min(...), max(...)
  • count(*)
  • count(...), count(distinct ...), count(all...)
You can use arithmetic operators, concatenation, and recognized SQL functions in the select clause:
select cat.weight + sum(kitten.weight)
from Cat cat
    join cat.kittens kitten
group by, cat.weight
select firstName||' '||initial||' '||upper(lastName) from Person
The distinct and all keywords can be used and have the same semantics as in SQL.
select distinct from Cat cat

select count(distinct, count(cat) from Cat cat