JorgeBPrado
JorgeBPrado

Reputation: 235

HQL Multiple selects in the select clause

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

Answers (1)

StackFlowed
StackFlowed

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

Related Questions