答案 0 :(得分:2)
您只获得了1
,因为您选择了用于分组的不同值的计数(n.id = ap.neighborhood
,因此n.id
与ap.neighborhood
相同})。
我假设您的查询的目标是与超过19 Neighborhood
s相关联的不同AirbnbProperty
的计数(当然,在应用所有其他条件之后)。如果是这样,你需要的基本上是这样的:
select count(*) from
(select n.id
from
... the rest of your query without group by ...
group by n.id having count(ap.id) > 19
)
但是,Hibernate不支持from
子句中的子查询,因此您必须使用in
运算符解决它:
select count(*) from Neighborhood n
where n.id in
(select n.id
from
... the rest of your query without group by ...
group by n.id having count(ap.id) > 19
)