-->
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: Order by an aggregated column
PostPosted: Wed Sep 28, 2005 1:25 am 
Beginner
Beginner

Joined: Fri Dec 10, 2004 11:46 pm
Posts: 37
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.7

Hi I'm running the current query which works fine...

Query q = hSession.createQuery("select count(log.artistID), log.artistID from StreamLog log group by log.artistID");
streamList = q.list();

But I would like to order my data by highest count desc. How would I go about this?

This is my actual MySQL query as well...
select count(artistid) as total, artistid from streamlog group by artistid order by total;


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 4:02 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Try this:

Query q = hSession.createQuery("select count(log.artistID) ct, log.artistID from StreamLog log group by log.artistID order by ct asc");

_________________
Vincent Giguère
J2EE Developer


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.