-->
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: Nested Aggregate Function -- HQL Help
PostPosted: Sun Dec 14, 2008 1:23 pm 
Newbie

Joined: Sun Dec 14, 2008 12:16 pm
Posts: 2
Location: Columbia, SC, USA
I am wondering if Hibernate handle nested aggregate function.

I am trying to find sum of average rating of articles for each user. I would also like to do rounding of this sum of avg rating..

Any Idea how to do this? Pl. let me know if more information is required in understanding the problem.. I am using msql db and hibernate 3.0

select r.article.user.userId, sum(avg(r.rating)) as points from Rating r group by r.article


Top
 Profile  
 
 Post subject: MySQL Query for this issue...
PostPosted: Sun Dec 14, 2008 6:55 pm 
Newbie

Joined: Sun Dec 14, 2008 12:16 pm
Posts: 2
Location: Columbia, SC, USA
Below is mysql query for this issue...It works perfectly fine and gives desired results...I tried coverting it to HQL but no luck...any thought, how to convert it to hql??

Quote:
select userId, round(sum(avgrating)) as points from (select a.User_Id as userId , avg(r.rating) as avgrating from article a, rating r where a.article_id = r.article_id group by r.article_id) as ratingsum group by userId order by sum(avgrating) desc


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.