-->
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.  [ 2 posts ] 
Author Message
 Post subject: Count() in ORDER BY?
PostPosted: Thu Jun 03, 2004 4:19 pm 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi,

I have a HQL like this:

Code:
select distinct t, count(t.film) from OrderItemTO as t group by t.film


which returns order items, grouped by film id. I'd like to sort it descending on the value of count(), but when I use:

Code:
select distinct t, count(t.film) as h from OrderItemTO as t group by t.film order by h desc


I receive a " , expected in SELECT " error message. how to order by a count() value?

Thanks is advance.
Thomas


Top
 Profile  
 
 Post subject: in mysql it works
PostPosted: Fri Jun 04, 2004 5:42 am 
Newbie

Joined: Thu Feb 12, 2004 12:21 pm
Posts: 13
Location: Hungary
hi,

I have to following query in MySQL:

Code:
select t.film, count(t.film) h from order_items t group by t.film order by h desc


That works well. The native sql as above works fine.

How to implement it to hibernate/HQL?

Please help!
regards,
Thomas

PS: Hibernate version 2.1.3.


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

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.