-->
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.  [ 4 posts ] 
Author Message
 Post subject: subQuery
PostPosted: Mon May 21, 2007 9:18 am 
Newbie

Joined: Mon Apr 02, 2007 6:33 am
Posts: 4
Hi I would like create SELECT that uses table in sub Query. But I have no Idea how to do that.

I tryed that but it does not work:
Code:
                   SELECT
                        TMP.ABC
                      FROM
                        (SELECT DISTINCT
                            a.ABC ABC, aa.DEF DEF, ar.FGH FGH,
                        FROM                       
                            X a, Y ar, Z aa
                        WHERE   
                            ar.ABC = a AND aa.ABC = a
                        ) AS TMP

Any Ideas how to do that ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 21, 2007 10:37 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

SQLQuery query=sess.createSQLQuery("select tmp.* from (select t1.SIC_CODE from Table1 t1,Table2 t2 where t1.id=t2.id) as tmp");

query.list();


Amila

(Don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 03, 2007 9:47 am 
Newbie

Joined: Mon Apr 02, 2007 6:33 am
Posts: 4
Thanks, But how to do that using HQL or other Hibernate features ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 28, 2008 7:30 am 
Newbie

Joined: Fri Apr 21, 2006 10:26 am
Posts: 1
I have the same problem.
want to use HQL and distinct subquery:

Code:
select count(pid), sum(age), color from
(select distinct persons.pid, persons.age, cars.color from cars,persons
where cars.owner_pid=persons.pid) as dummy
group by color


but cant get it to work.


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