How to use the Count Query. Hibernate supports multiple aggregate functions. when they are used in HQL queries, they return an aggregate value (such as sum, average, and count) calculated from property values of all objects satisfying other query criteria. These functions can be used along with the distinct and all options, to return aggregate values calculated from only distinct values and all values (except null values), respectively. Following is a list of aggregate functions with their respective syntax; all of them are self-explanatory. count( [ distinct | all ] object | object.property )
count(*) (equivalent to count(all ...), counts null values also)
sum ( [ distinct | all ] object.property)
avg( [ distinct | all ] object.property)
max( [ distinct | all ] object.property)
min( [ distinct | all ] object.property)
_________________ r4 gold ds
|