Hibernate AVG method: calculate the average value of a column
•
Java
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
二维码