I'm trying to make a report query that shows how many distinct entities appear a certain number of times, so that I can make a graph of it showing the number of appearances against the number of entities.
The result of the query should be a table like :
Code:
#appearances | #entities
-----------------------------
12 | 1
10 | 2
5 | 15
2 | 37
I created a SQL-query of the following form:
Code:
select count(count_ent) as freq, count_ent from
(
select count(ent_name) count_ent from tbl_entity
group by ent_name
) as tbl1
group by count_ent
order by freq desc, count_ent desc;
Can this query be translated into HQL?
In a Criteria-query?
How?
I've read in the documentation and in "Hibernate in Action" that subqueries are not supported in the from-clause, but I don't know how to do this query otherwise.
Any help is appreciated.