开发者

hql select from select problem

I would like to count the number of groups of a group by statement. In SQL that would look like:

select count(*) from (select count(*) from MyTable t group by t.col1, t.col2) g

But in HQL it seems I can not do a select in a select as I did in the previous sql. I guess the problem is that Hibernate does not support subquery in the from clause. Is there 开发者_如何学Goany way to do this in hql?


Well, I have finally run the following query in hql:

select count(*) from MyTable t group by t.col1, t.col2

and then used the size of the returned list, which is exactly the number of groups.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜