hibernate内部select in from子句
我想知道是否可以在 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;
我需要这样的查询,以便将计数数字作为外部查询中的额外列。 我不知道如何在 from 中指定 select 语句,无论是使用 hql 还是条件。
谢谢。
卢卡
I'd like to know if it's possible to specify a select clause in a from clause something like
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;
I need a query like this in order to have the count number as an extra column in the outer query.
I can't find out how to specify a select statement in a from, neither with hql nor with criteria.
Thank you.
Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Hibernate 文档,HQL 子查询只能出现在 select 或 where 子句中:
Hibernate 社区文档,第 16 章。HQL - 16.3。子查询
According to Hibernate documentation HQL subqueries can occur only in the select or where clauses:
Hibernate Community Documentation, Chapter 16. HQL - 16.3. Subqueries