-->
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: Aggregate functions on collections
PostPosted: Wed Mar 02, 2005 3:18 pm 
Beginner
Beginner

Joined: Fri Mar 19, 2004 7:21 am
Posts: 20
Hi,
I'm having trouble with a tricky aggregate HQL query.

I am querying for Item records that have collections of Keyword. I would like to count the total number of keywords found across the set of Item objects found.

My standard query looks like..
"from Item a join a.keywords k where a.title like ? or a.description like ?"

I want to return something like..
"select k.name, count(k)"

And presumably I need a group by..
"group by k.keywordId order by count(k) ASC"

But count(k) is always 1 at the moment. Presumably I am getting the count of number of keywords in each Item rather than number of keywords over the total set.

Can anyone point me in the right direction?

Regards,
Damon.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.