Hibernate AVG method: calculate the average value of a column

avg(String propertyName)

Example

Criteria criteria = session.createCriteria(ResultForm.class);  //定义Criteria对象
criteria.setProjection(Projections.avg("achievement"));  //计算achievement列的平均值
double avg = (Double)criteria.uniqueResult();  //获取计算结果
System.out.println("平均成绩:"+avg);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>