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.  [ 2 posts ] 
Author Message
 Post subject: IS THIS ORDER BY QUERY IS CORRECT?
PostPosted: Fri Aug 04, 2006 4:35 am 
Newbie

Joined: Tue Aug 01, 2006 8:31 am
Posts: 6
Hi all,
I have a table Allotment where i have two fields noOfAttempt and one foregn Key User_Id(User table is having UserName and Date Of Birth). Now i have to sort the records in the Allotment table based on the noOfAttempt and age. But Date Of Birth is there in the User Table.

How can i solve this problem.
Can i write a query like this.

FROM com.Allotment allotInfo order by allotInfo.noOfAttempt desc,allotInfo.User.userDob.

if it is wrong please help me out its an urgent requirement for me.

Is there any other way of sorting the records in this table please help me out its an urgent requirement for me

Regards
Sreenivasula Reddy A


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 5:36 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Try this:

Code:
FROM com.Allotment allotInfo
inner join User as usr
order by allotInfo.noOfAttempt,usr.userDob desc


I beleive this will also work:

Code:
FROM com.Allotment allotInfo order by allotInfo.noOfAttempt ,allotInfo.User.userDob desc


Note: This is the same query as your posting but the "desc" should appear at the end of all the columns in your order by.


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