-->
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: Convert SQL query to HQL query
PostPosted: Fri Mar 05, 2010 7:48 am 
Newbie

Joined: Thu Oct 25, 2007 10:24 am
Posts: 2
Hi all.

I need some help to convert this SQL query to HQL:

Code:
select c1.code, count(*)
from (select min(myDate) as myDate,serialNumber,code from TableXpto
where actual_state ='OK' group by serialNumber) as c1
where c1.myDate >= '2009-01-01' and c1.myDate <= '2010-03-20'
group by c1.code


If you take a look you see that i have one sub query and that's why i'm having problems to convert this query.

Thx for your help.


Top
 Profile  
 
 Post subject: Re: Convert SQL query to HQL query
PostPosted: Mon Mar 08, 2010 5:10 am 
Newbie

Joined: Thu Oct 25, 2007 10:24 am
Posts: 2
Well, i don't have a solution for this problem...
I was trying this query but don't work....

Code:
select c1.code, count(c1.id)
from TableXpto c1
where
c1.myDate>='2009-01-01' and
c1.myDate<='2010-03-20' and
c1.myDate exists (
   select min(c1.myDate) ,c1.serialNumber,c1.code
   from c1
   where
   c1.actual_state='OK'  group by c1.serialNumber
   )
group by c1.code


Why?!

Please i really need some 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.