hibernate内部select in from子句

Luc*_*uca 13 select hibernate hql criteria

我想知道是否可以在from子句中指定一个select子句

select count(*) as Y, this_.NAME as A, sel2.C
from TABLE1 this_, 
    (select count(*) as C from 
        (select this_.NAME, this_.SEX 
        from TABLE1 this_ group by this_.NAME, this_.SEX) sel1
    ) sel2
group by this_.NAME, sel2.C;
Run Code Online (Sandbox Code Playgroud)

我需要这样的查询,以便将计数作为外部查询中的额外列.我无法找到如何在from中指定select语句,既不使用hql也不使用条件.

谢谢.

卢卡

小智 12

根据Hibernate文档,HQL子查询只能出现在select或where子句中:

Hibernate社区文档,第16章.HQL - 16.3.子查询