-->
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: Group by Query order by the sum value result
PostPosted: Tue Oct 17, 2006 7:57 pm 
Newbie

Joined: Thu Jan 08, 2004 8:57 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

2.1.2

I am trying to do a group by query order as

select aorder.customer.id, sum(a.order.amount) from CustomerOrder aorder group by aorder.customer.id

it works perfectly. However if i want to sort the result order by the result of sum, it does not work. the query as


select aorder.customer.id, sum(a.order.amount) as totalAmount from CustomerOrder aorder group by aorder.customer.id order by totalAmount desc.


Can anyone help this out? Obviously I can put the result in a object and sort the list in java code. But I really want to know the way it works in Hibernate.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 2:22 am 
Newbie

Joined: Thu Jan 08, 2004 8:57 pm
Posts: 6
Can i use

select aorder.customer.id, sum(a.order.amount) from CustomerOrder aorder group by aorder.customer.id order by sum(a.order.amount) desc

in hibernate 2.1.2?


Thanks for any help


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.