JPA Is there a way to do something like SELECT <field>, count(*) FROM <table> GROUP BY <field>

Posted by javydreamercsw on Stack Overflow See other posts from Stack Overflow or by javydreamercsw
Published on 2010-05-28T15:45:51Z Indexed on 2010/05/28 17:52 UTC
Read the original article Hit count: 233

Filed under:
|

I've been looking in the web for examples on the aggregates like count but it seems all of them are using the aggregate alone.

SELECT field, count(*) FROM table GROUP BY field

Should have something like:

field.value1, x1
field.value2, x2
....

I'm looking for a pure JPA answer for this one. If not I guess I can then do further queries just for the count part but that seems unefficient.

Any ideas?

© Stack Overflow or respective owner

Related posts about jpa

Related posts about jql