Reputation: 235
I would like to get in a single query the result of multiple counts. In a native query I can do that like:
`select (select count(*) from Foo where status = 1), (select count(*) from Foo where status = 2) ...`
If I do like that in HQL:
select (select count(f) from Foo f where f.status = 1), (select count(f) from Foo f where f.status = 2)
I get an error:
<AST>:0:0: unexpected end of subtree
How can I do that in HQL?
Upvotes: 0
Views: 1947
Reputation: 6816
Your first select is incomplete if you complete it it should be fine.
select (select count(f) from Foo f where f.status = 1), (select count(f) from Foo f where f.status = 2) from Foo;
Upvotes: 1