IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

The best optimum query to find nth highest salary


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
itssrikanth4u

New User


Joined: 21 Nov 2004
Posts: 9

PostPosted: Sat Dec 11, 2004 5:48 pm
Reply with quote

Hi,

Can any one please tell me the best optimum query to find nth highest salary?

bye
thanx in advance
take care
srikanth
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Mon Dec 20, 2004 4:36 pm
Reply with quote

Hi,

Once check and post one question only once. Other wise all of us are wasting time by opening duplicate queries. MODERATOR may not alert and aware about the things like duplicates. Please delete duplicates frequently and faciliate users.

If any one first opens this query for answer i dont want to disappoint them. So here is your answer...

SELECT SAL FROM TABLEA A WHERE N=(SELECT COUNT(DISTINT *) FROM TABLEA B WHERE A.SAL<=B.SAL);

FOR TOP N SALARIES JUST CHANGE CONDITION AS

N<= INSTEAD OF N=.

OK BYE,
O.V.Reddy.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
Search our Forums:

Back to Top