-->
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: Calculations on multiple subqueriy results in 1 HQL query
PostPosted: Fri Jul 28, 2006 2:54 pm 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
I am trying to use the results or two subqueries in a simple calculation. What I need to do is limit the results in the where clause to
Code:
where reclassify.numpieces -
          numCommitted - (I could find no way to alias the subqueries and have no problem repeating the subquery here as I did in the full query below)
          numCompleted                         


I can tweak the generated sql easily to do the simple subtraction of the subquery results, but I want this to work in HQL. Any help would be greatly appreciated.

Code:
select reclassify as reclassify,
      (
        select coalesce(sum(c.numPieces),0)
       from Coupling c
        where c.state.id=reclassify.id
      ) as numCommitted, 

       (
         select coalesce(sum(c2.numPieces),0)
         from Coupling c2
         where c2.state.parentState.id=reclassify.id
       ) as numCompleted                         
from Reclassify reclassify
where (
        select coalesce(sum(c.numPieces),0)
        from Coupling c
        where c.state.id=reclassify.id
      )>0

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


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.