-->
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: HQL
PostPosted: Thu Feb 19, 2004 4:31 pm 
Newbie

Joined: Mon Oct 06, 2003 2:20 pm
Posts: 10
I have a that table have 3 fields

PK, goalID,ranking

it has the following data:

PK,Goalid, ranking
1,1,1
2,1,2
3,1,3
4,2,1
5,2,2
6,2,3
7,3,1
8,3,2
9,3,3
10,4,1
11,4,2
12,4,3
13,4,4

How can I using HQL query to get the result that return all all goals with the higest ranking?

I'd like to get a result like
3,1,3
6,2,3
9,3,3
13,4,4

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 4:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Code:
select goal from Goal goal where ranking >= all (select goal2.ranking from Goal goal2)


or something like that. Only with subselects though.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 7:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No this won't work, you'll only have 13,4,4
Maybe
Code:
select goal from Goal goal where ranking >= all (select goal2.ranking from Goal goal2 and goal.id = goal2.id)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 7:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Ah sorry, my query was wrong of course :( Take Emmanuels example.


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.