17

I'd like to know if it's possible to specify a select clause in a from clause something like

select count(*) as Y, this_.NAME as A, sel2.C
from TABLE1 this_, 
    (select count(*) as C from 
        (select this_.NAME, this_.SEX 
        from TABLE1 this_ group by this_.NAME, this_.SEX) sel1
    ) sel2
group by this_.NAME, sel2.C;

I need a query like this in order to have the count number as an extra column in the outer query. I can't find out how to specify a select statement in a from, neither with hql nor with criteria.

Thank you.

Luca

animuson
  • 53,861
  • 28
  • 137
  • 147
Luca
  • 171
  • 1
  • 1
  • 4
  • 1
    Can you provide some more information on your query? What is your model and what you are looking for. The query seems to be nonsense for me... – GaetanZ Aug 02 '11 at 22:33

1 Answers1

14

According to Hibernate documentation HQL subqueries can occur only in the select or where clauses:

Hibernate Community Documentation, Chapter 16. HQL - 16.3. Subqueries

sayYeah
  • 166
  • 1
  • 5