-->
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: Assigned aggregate value of inner select to an alias
PostPosted: Tue Oct 12, 2004 4:55 pm 
Newbie

Joined: Tue Oct 12, 2004 4:27 pm
Posts: 2
Hibernate version: 2.1.1

Name and version of the database you are using: Oracle 9i

I am trying to figure out how to, or a better way to do an inner select with an aggregate function to an alias. I have 3 tables and table 2 and 3 are children of table 1. I'm trying to do a sum() on a column in table 2 and 3 and compare the values returned. Then return table 1 with those sum() values of the 2 inner selects. I first tried assigning the value of the inner selects to an alias and added that alias to the outer select, but I get an exception where it doesn't recognize the alias. Here is the hql that I was trying to do:

select sc, expected_volume, actual_volume from SourceCode as sc where (select sum(invoice.quantity) from InvoiceDetail as invoice where sc.pk.ftfId = invoice.pk.ftfId and sc.pk.mailpieceId = invoice.pk.mailpieceId and sc.pk.sourceCodeId = invoice.pk.sourceCodeId) as actual_volume > (select sum(dist.volume) from Distribution as dist where sc.pk.ftfId = dist.pk.ftfId and sc.pk.mailpieceId = dist.pk.mailpieceId and sc.pk.sourceCodeId = dist.pk.sourceCodeId and dist.pk.startDate < sysdate) as expected_volume and sc.mailpiece.companyId = :companyId

Does anyone have any suggestions of a way to make this work?

thanks in advance.


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