GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Manhattan Associates  >  SQL
Next Question 
 SQL  |  Question 1 of 4    Print  
Write query to find the employees with top 5 salaries ?

  
Total Answers and Comments: 9 Last Update: December 26, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 18, 2005 15:33:40   #1  
Ritu        

RE: Write query to find the employees with top 5 salaries ?
select empno sal from emp X where ( select count(*) from emp where sal > X.sal ) < 5order by sal desc;
 
Is this answer useful? Yes | No
May 30, 2005 01:26:13   #2  
Amit        

RE: Write query to find the employees with top 5 salaries ?
select ename sal from emp X where (select count (*) from emp where sal > X.sal) < 5 order by sal desc ;
 
Is this answer useful? Yes | No
June 06, 2005 07:20:59   #3  
Nagaraja Rao S.K        

RE: Write query to find the employees with top 5 salaries ?
select ename sal from emp where rownum< 5
order by sal desc

 
Is this answer useful? Yes | No
June 13, 2005 05:17:35   #4  
varsha        

RE: Write query to find the employees with top 5 salaries ?
select distinct sal from emp where sal > (select distinct a.sal from emp a where (&n-1) (select count(unique sal) from emp b where b.sal > a.sal)) order by sal desc
 
Is this answer useful? Yes | No
December 13, 2005 00:22:12   #5  
santhosh        

RE: Write query to find the employees with top 5 salar...
select top 5 EmpName Salary from Emp_Table
order by Salary desc

 
Is this answer useful? Yes | No
May 03, 2006 09:17:12   #6  
AMIT Jain        

RE: Write query to find the employees with top 5 salar...
select top 5 k.emp_id k.salary from (select top 8 * from emp
order by salary desc) k order by k.salary desc

 
Is this answer useful? Yes | No
January 30, 2007 10:36:14   #7  
madug Member Since: January 2007   Contribution: 2    

RE: Write query to find the employees with top 5 salar...
select empno sal rownum from ( select empno sal from emp order by sal desc) where rownum < 5
 
Is this answer useful? Yes | No
January 30, 2007 10:43:24   #8  
madug Member Since: January 2007   Contribution: 2    

RE: Write query to find the employees with top 5 salar...
hai u r query may not give the top 5 salaries
 
Is this answer useful? Yes | No
December 26, 2007 02:55:00   #9  
mkgreets Member Since: December 2007   Contribution: 1    

RE: Write query to find the employees with top 5 salaries ?

This is the solution if you want the sql to run in SQL Server 2005 :
--------------------------------------------------------------

select * from employee

where sal in(select distinct top 5 sal from employee order by sal desc)

order by sal desc

---------------------------------------------------------------

Hope it will work for you .
Happy Programming..........


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape