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.  [ 3 posts ] 
Author Message
 Post subject: How to count the results of group by
PostPosted: Mon Feb 22, 2010 11:17 am 
Beginner
Beginner

Joined: Sun Jan 24, 2010 3:04 am
Posts: 20
Hi!

I have this query:
select count(job_id) from (select job_id from life where job_id=? group by plan_id) as tmptable;

i need to count the amount of plan_id in life where job_id equals to something.

Is there a better way to achieve it with hibernate?

i use createQuery and put the properties of the classes


Top
 Profile  
 
 Post subject: Re: How to count the results of group by
PostPosted: Mon Feb 22, 2010 11:38 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
select count(distinct plan_id) from life where job_id=?


Top
 Profile  
 
 Post subject: Re: How to count the results of group by
PostPosted: Mon Feb 22, 2010 11:54 am 
Beginner
Beginner

Joined: Sun Jan 24, 2010 3:04 am
Posts: 20
thanks!
it works!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.