ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Databases  >>  DB Development
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
Given an employee table, how would you find out the second 
highest salary?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Given an employee table, how would you find out the second highest salary?
Answer
# 1
select * from emp
 where n-1 = (select count(*) from emp e 
 where emp.salary<e.salary)

in place of n-1 you can keep zero for first hight salary 
and 1 for second hightest salary.....etc
 
Is This Answer Correct ?    1 Yes 0 No
Trived
 
  Re: Given an employee table, how would you find out the second highest salary?
Answer
# 2
select salary from tablename order by salary desc limit 1,1;
 
Is This Answer Correct ?    0 Yes 0 No
Vivek Mohan Singh
 
 
 
  Re: Given an employee table, how would you find out the second highest salary?
Answer
# 3
Select * from emp where sal=(select Max(sal) from emp where 
sal<(select Max(Sal) from emp)
 
Is This Answer Correct ?    0 Yes 0 No
Sowjanya
 
  Re: Given an employee table, how would you find out the second highest salary?
Answer
# 4
select top 1 a.salary,* from emp a
where a.salary not in(select top (n-1) b.salary from emp b)

here n is the Nth values:if you want secong highest: keep n 
as 2 so the query will become

select top 1 a.salary,* from emp a
where a.salary not in(select top 1 b.salary from emp b)
 
Is This Answer Correct ?    1 Yes 0 No
Karna
 

 
 
 
Other DB Development Interview Questions
 
  Question Asked @ Answers
 
What is denormalization and when would you go for it?  2
Explain the general syntax for a SELECT statements covering all the options.  2
Define candidate key, alternate key, composite key?  6
What is a self join? Explain it with an example?  2
what is Normalization? TCS2
What is the system function to get the current user's user id?  1
How do you implement one-to-one, one-to-many and many-to- many relationships while designing tables? SQL-Star1
What are cursors? Explain different types of cursors?  3
What is normalization? Explain different levels of normalization? IBM2
What is bit datatype and what's the information that can be stored inside a bit column?  2
What are the disadvantages of cursors? How can you avoid cursors?  1
What is an extended stored procedure?  1
how will I find the duplicate rows count from employees tablein oracle.  1
What are defaults? Is there a column to which a default can't be bound?  1
Given an employee table, how would you find out the second highest salary?  4
 
For more DB Development Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com