-->
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.  [ 7 posts ] 
Author Message
 Post subject: How to give alias for nested queries
PostPosted: Tue Sep 16, 2008 3:19 am 
Newbie

Joined: Tue Sep 16, 2008 2:33 am
Posts: 4
I am not able to find how to write this type of query in HQL

select a.x, b.y from
(select x,ab from tab1 where xxxxxx) as a and
(select y.ab from tab2 where xxxxxx) as b
where a.ab = b.ab;

Can anyone let me know how to write it or any link to verify for it.


Top
 Profile  
 
 Post subject: re
PostPosted: Tue Sep 16, 2008 3:46 am 
Newbie

Joined: Fri Aug 29, 2008 9:07 am
Posts: 16
Location: edinburgh/zielona gora
Could you give real query please? I wounder if you need nested query at all.

cheers


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2008 4:25 am 
Newbie

Joined: Tue Sep 16, 2008 2:33 am
Posts: 4
Sorry, I cant give you the exact query, but trust me it is required since the second query is not just a simple select it consists of sum's and counts from another table

it is exactly something like

select a.x, b.y from
(select x,ab from tab1 where xxxxxx) as a and
(select sum(ab),sum(ac) as y from tab2 where xxxxxx) as b
where a.ab = b.ab;

first inner query is a select statement where as the second query is a calculated query.


Top
 Profile  
 
 Post subject: re
PostPosted: Tue Sep 16, 2008 4:44 am 
Newbie

Joined: Fri Aug 29, 2008 9:07 am
Posts: 16
Location: edinburgh/zielona gora
at last could you describe ralations in xxxx if there are any
cheers


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2008 5:03 am 
Newbie

Joined: Tue Sep 16, 2008 2:33 am
Posts: 4
This is a smaller version of the actual query

I think this will help you get what i am trying to say.

SELECT TS.ROUTE_QTY,0, RR.INCR_STOPS_QTY
FROM
(SELECT VTSR.ROUTE_QTY, VRTS.VRPS_RUN_TS_OID_NBR
FROM VRPS_RUN_STATUS VRS, VRPS_RUN_TIME_SEGMENT VRTS,
VRPS_TIME_SEGMENT_RESULT VTSR
WHERE
VRTS.VRPS_RUN_OID_NBR = VRS.VRPS_RUN_OID_NBR
AND VRTS.VRPS_RUN_TS_OID_NBR = VTSR.VRPS_RUN_TS_OID_NBR (+)
AND VRS.DAY_PLAN_OID_NBR = :dayPlanID
) TS,
(SELECT VRTS.VRPS_RUN_TS_OID_NBR AS VRPS_RUN_TS_OID_NBR,
SUM(VRLT.INCR_STOPS_QTY) AS INCR_STOPS_QTY
FROM VRPS_RUN_STATUS VRS, VRPS_RUN_TIME_SEGMENT VRTS, VRPS_ROUTE_LEVEL_RESULT VRLT
WHERE VRTS.VRPS_RUN_OID_NBR = VRS.VRPS_RUN_OID_NBR
AND VRTS.VRPS_RUN_TS_OID_NBR = VRLT.VRPS_RUN_TS_OID_NBR
AND VRS.DAY_PLAN_OID_NBR = :dayPlanID
AND VRS.VRPS_RUN_TYPE_NBR = :executionType
GROUP BY VRTS.VRPS_RUN_TS_OID_NBR
) RR WHERE TS.VRPS_RUN_TS_OID_NBR = RR.VRPS_RUN_TS_OID_NBR (+)

regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 16, 2009 6:54 pm 
Newbie

Joined: Sun Feb 22, 2009 8:48 pm
Posts: 1
Location: Boston
Did you find a solution to this problem?

_________________
Tech Beenie


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 17, 2009 12:25 am 
Newbie

Joined: Tue Sep 16, 2008 2:33 am
Posts: 4
No,
I changed the query and hbm files to enable inner joins so that this type of query need not be used.

I exactly don't remember the exact steps :)


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