The largest Interview Solution Library on the web

Hibernate Tutorials/
« Previous | 1 | 2 | 3 | Next »
HQL supports a range of aggregate methods, similar to SQL. They work the same way in HQL as in SQL and following is the list of the available functions:
1avg(property name)The average of a property's value
2count(property name or *)The number of times a property occurs in the results
3max(property name)The maximum value of the property values
4min(property name)The minimum value of the property values
5sum(property name)The sum total of the property values
The distinct keyword only counts the unique values in the row set. The following query will return only unique count:

String hql ="SELECT count(distinct E.firstName) FROM Employee E";
Query query =session.createQuery(hql);
List results =query.list();
« Previous | 1 | 2 | 3 | Next »

copyright © 2014 - all rights riserved by