-->
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: Problem with Subquery
PostPosted: Sun Apr 17, 2005 2:29 am 
Newbie

Joined: Wed Mar 23, 2005 8:20 am
Posts: 2
Hi all ,
I am using Hibernate 2.0 can anyone help me in getting the HQL equivalent of the following query ?

SELECT commoditycode,
orderdate,
(select min(price) as buy from teorders b where commoditycode='RC2' and ordertype='B' and b.orderdate=a.orderdate and b.orderstatus='TRADE') as buy
from teorders a
where commoditycode='RC2'
GROUP by ORDERdate

Thanks in Advance
Cathy


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 18, 2005 2:04 am 
Beginner
Beginner

Joined: Fri Oct 10, 2003 10:12 am
Posts: 39
Hi Cathy,

I can't tell exactly what you're trynig to accomplish from this query but it looks like you want something similar to an example in the Hibernate documentation:

Code:
select count(payment), status.name
from Payment as payment
join payment.currentStatus as status
join payment.statusChanges as statusChange
where payment.status.name <> PaymentStatus.AWAITING_APPROVAL
or (
statusChange.timeStamp = (
select max(change.timeStamp)
from PaymentStatusChange change
where change.payment = payment
)
and statusChange.user <> :currentUser
)
group by status.name, status.sortOrder
order by status.sortOrder


Also you can't do subqueries or assign names in the select clause.

Cameron


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.