我有一个hql查询,我需要以某种方式对它们进行分组。所以这个查询看起来像这样:
SELECT a1,a2,a3
FROM tablename
GROUP BY a1,a2,a3;
我想计算此查询的结果,但不使用子查询(据我所知,HQL无法从子查询中选择):
/* I don't want to do it in this way because of HQL */
SELECT count(*) FROM (
SELECT a1,a2,a3
FROM tablename
GROUP BY a1,a2,a3
);
那么有没有办法计算没有子查询的分组结果?
答案 0 :(得分:-3)
实施例: String SQL_QUERY =“SELECT student.course,COUNT(student.course)FROM Student student GROUP BY student.course”;
请浏览此链接
http://www.dineshonjava.com/2012/05/hql-group-by-clause-example.html#.VCKxBfmSzt4