-->
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: using TOP in subquery
PostPosted: Wed Apr 02, 2008 3:35 am 
Newbie

Joined: Wed Apr 02, 2008 3:13 am
Posts: 1
I need to use the TOP qualifier in a subquery in an HQL query.
However I understand that the TOP keyword is not supported in HQL.
I need to get complex aggregate and grouped data (from many tables) using a complex query, based on a singe id returned from a subquery which gets a row by the latest date.

The subquery needs to be something like
Code:
SELECT TOP 1 s.id FROM Stuff s WHERE s.user = :user ORDER BY s.date DESC


Then the main query gets a pile of useful aggregate and other information based on the one id returned from the subquery.

Of course I can do this using two HQL queries.

I am using Hibernate 3.2.2ga, SQLServer 2005

Thank you!


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.