Click here to Skip to main content
11,712,802 members (82,820 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL DBMS
write a query to select the 5th higest salary record from table employee
plz explain the query too
Posted 20-Sep-12 1:47am
Comments
Wes Aday at 20-Sep-12 7:48am
   
Uhm.... no.... do your own homework and you would be able to explain it yourself.
Member 9239619 at 20-Sep-12 7:50am
   
i have an interview tomorrow so m asking
Malli_S at 20-Sep-12 7:52am
   
Then better you should have googled. Or should have referred to some reference book. Why wasting time here.
vithal wadje at 20-Sep-12 7:51am
   
gud gud best of luck i will reply
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,

Please see the below article and review it. i hope you will get answer.

http://blog.sqlauthority.com/2008/04/02/sql-server-find-nth-highest-salary-of-employee-query-to-retrieve-the-nth-maximum-value/[^]

Thanks,
Viprat
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

try this soln.it works i haved trid

select  * from
(select empId,salary,RANK() over (order by salary desc) as rank  from Emp ) as p
where rank=5
  Permalink  
Comments
vithal wadje at 20-Sep-12 8:20am
   
great vijay sir
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can simply use the Tophttp://msdn.microsoft.com/en-us/library/ms189463.aspx[^] keyword.
However, that is not the solution the interviewer would most likely be looking for.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CHill60 335
1 Sergey Alexandrovich Kryukov 290
2 OriginalGriff 200
3 Andy Lanng 165
4 Maciej Los 130
0 CHill60 335
1 Sergey Alexandrovich Kryukov 300
2 OriginalGriff 230
3 Andy Lanng 160
4 Maciej Los 130


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 20 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100