Hello. My name is Sorin
I am using Hibernate 2.1.7
I have the following HQL query:
<query name="note.noteperuser">
<![CDATA[
select note.user_id, count(note)
from tourism.model.Note note
where ((:start is null or note.data>=:start) and (:stop is null or note.data<=:stop))
group by note.user_id
]]>
</query>
I want also to order desc the result of this query by the number of notes, so I want
a kind of "order by count(note) desc"
I tried to rewrite this query like
<query name="note.noteperuser">
<![CDATA[
select note.user_id, count(note) as nonotes
from tourism.model.Note note
where ((:start is null or note.data>=:start) and (:stop is null or note.data<=:stop))
group by note.user_id
order by nonotes desc
]]>
</query>
but it doesn't work.
Do you know how can I order by the number of notes the result set?
Thank you very much.
Sorin
|