-->
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: Select clause in HQL
PostPosted: Thu Feb 19, 2009 8:23 am 
Newbie

Joined: Tue Oct 02, 2007 1:47 am
Posts: 6
HQL for select clause that contains :

1. columns
2. count(columnname) - to hold value of total records selected by the query.
3. sum(columnname) - to hold summation of value for all the records for the specified column name.

Can a HQL, serve this purpose ? How does the HQL look like in this case?


Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 8:46 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
It could be like:
Code:
select propertyOne, propertyTwo, count(*), sum(propertyThree) from MyEntity group by propertyOne, propertyTwo


Notice: if you execute this query no Entity but a List of Arrays.
Do I understand your usecase right? You also want the aggregates to be grouped by the selected columns?

_________________
-----------------
Need advanced help? http://www.viada.eu


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