-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: order by using an alias for a count function?
PostPosted: Wed May 18, 2005 3:14 am 
Newbie

Joined: Wed May 18, 2005 2:51 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.