GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Testing  >  DataBase Testing
Go To First  |  Previous Question  |  Next Question 
 DataBase Testing  |  Question 14 of 50    Print  
Write a query to find the second largest value in a given column of a table

  
Total Answers and Comments: 18 Last Update: February 27, 2008     Asked by: Thiagu1978 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
  Sorting Options  
  Page 1 of 2   « First    1    2    >     Last »  
February 23, 2006 10:22:53   #1  
Gauri Shankar Arya        

RE: Write a query to find the second largest value in ...

To find the second largest salary amount from employee table

select max(salary) from employees
where pin < (select max(salary) from employees)


 
Is this answer useful? Yes | No
March 02, 2006 03:53:47   #2  
ferozbm Member Since: February 2006   Contribution: 43    

RE: Write a query to find the second largest value in ...
select max(sal) from emp_table where sal < (select max(sal) from emp_table)
 
Is this answer useful? Yes | No
March 24, 2006 14:35:38   #3  
veenadevi karumanchi        

RE: Write a query to find the second largest value in ...
select * from emp where score (select max(score) from emp where score<(select max(score)from emp));
 
Is this answer useful? Yes | No
April 02, 2006 13:00:19   #4  
JEELU        

RE: Write a query to find the Nth largest value in ...

To find Nth largest salary (not only second largest salary) the query is :

select sal from emp e where &n (select count(*) from emp

where e.sal< sal)


 
Is this answer useful? Yes | No
April 06, 2006 08:06:16   #5  
shashi singh        

RE: Write a query to find the second largest value in ...

Select * from EMP E1 where (N-1) (Select count(salary) from EMP E2 where salary.E2>salary.E1)


 
Is this answer useful? Yes | No
April 13, 2006 03:05:29   #6  
pravinshetty76 Member Since: April 2006   Contribution: 1    

RE: Write a query to find the second largest value in ...

hi feroz

You answer is corect. Thanks!!!

Pravin


 
Is this answer useful? Yes | No
May 12, 2006 08:39:05   #7  
sharad        

RE: Write a query to find the second largest value in ...

To Select Second highest Salary from Emp Table:

Query: Select Max(Distinct(a.sal)) from emp a where 2 select (count (distinct(sal)) from emp b where a.sal<b.sal )


 
Is this answer useful? Yes | No
May 17, 2006 21:27:24   #8  
jayakumar        

RE: Write a query to find the second largest value in ...
select sal(max) form employee where sal >(select sal(max) from employee)
 
Is this answer useful? Yes | No
August 28, 2006 16:04:54   #9  
Rajani        

RE: Write a query to find the second largest value in ...

For any question of this type .. just follow the simple methodology called TOP N ANALYSIS.

For the 3rd highest salary employee

Select emp_name rownum

From (select emp_name from emp Order by sal DESC)

where rownum 3.

For further clarification just test the similar type of queries with this methodology.


 
Is this answer useful? Yes | No
September 05, 2006 08:02:27   #10  
sanjeev        

RE: Write a query to find the second largest value in ...

Feroz's Query is correct. It correctly finds the 2nd largest number in a table.

Can any one plz give the same for nth highest number?

Thanks

Sanjeev Kumar Jha


 
Is this answer useful? Yes | No
  Page 1 of 2   « First    1    2    >     Last »  


 
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