Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
write a query to select the 5th higest salary record from table employee
plz explain the query too
Posted
Comments
[no name] 20-Sep-12 7:48am    
Uhm.... no.... do your own homework and you would be able to explain it yourself.
Member 9239619 20-Sep-12 7:50am    
i have an interview tomorrow so m asking
Malli_S 20-Sep-12 7:52am    
Then better you should have googled. Or should have referred to some reference book. Why wasting time here.
[no name] 20-Sep-12 7:51am    
gud gud best of luck i will reply

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
 
Share this answer
 
try this soln.it works i haved trid

SQL
select  * from
(select empId,salary,RANK() over (order by salary desc) as rank  from Emp ) as p
where rank=5
 
Share this answer
 
Comments
[no name] 20-Sep-12 8:20am    
great vijay sir
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900