ALLInterview.com :: Home Page            
 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                      
Google
   
 
Categories >> Software >> Databases >> SQL PLSQL
 
 


 

 
 Oracle interview questions  Oracle Interview Questions (2035)
 SQL Server interview questions  SQL Server Interview Questions (1075)
 MS Access interview questions  MS Access Interview Questions (24)
 MySQL interview questions  MySQL Interview Questions (194)
 Postgre interview questions  Postgre Interview Questions (6)
 Sybase interview questions  Sybase Interview Questions (22)
 DB Architecture interview questions  DB Architecture Interview Questions (5)
 DB Administration interview questions  DB Administration Interview Questions (213)
 DB Development interview questions  DB Development Interview Questions (53)
 SQL PLSQL interview questions  SQL PLSQL Interview Questions (768)
 Databases AllOther interview questions  Databases AllOther Interview Questions (106)
Question
Write a query to get 2nd maximum salary in an employee table ?
 Question Submitted By :: Wgk
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 1
select empno,ename,sal
from (select ename,empno,sal,dense_rank()
over(order by sal desc)topn
from emp)
where topn=2
 
Is This Answer Correct ?    61 Yes 45 No
Sohail
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 2
select max(sal) from emp where sal<(select max(sal) from
emp))
 
Is This Answer Correct ?    189 Yes 36 No
M
 
 
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 3
Crete Table Curtest(Emp char(40),salary money)
------------------------------------------------
Select Min(Salary) from Curtest where Salary
in (select Top 2 Salary from Curtest)

--------------------------------------------------
 
Is This Answer Correct ?    21 Yes 33 No
Rajesh.m
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 4
select * from emp a where 2=(select count(distinct sal)
from emp b where a.sal<=b.sal)
 
Is This Answer Correct ?    40 Yes 8 No
Anil_abbireddy
[MNC]
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 5
select * from emp a where 2=(select count(distinct sal)
from emp b where a.sal<=b.sal)
 
Is This Answer Correct ?    27 Yes 6 No
Anil_abbireddy
[MNC]
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 6
SELECT MAX(SAL) FROM EMPLOYEE WHERE SAL<(SELECT MAX(SAL)
FROM EMPLOYEE);



THIS will surly give 2^nd max sal ok this correct ans ok....
 
Is This Answer Correct ?    75 Yes 13 No
Kotravel. B
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 7
Hi,


Select * from emp e where 2>= (select count(sal) from
emp e where sal>=e.sal) order by desc.

Let me know if it is wrong..


Regards,
Satya.K
 
Is This Answer Correct ?    11 Yes 16 No
Satya_k21
[Igate]
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 8
select rownum,empno,ename,job,sal from emp(select
rownum,empno,ename,job,sal from emp order by sal desc) grop
by rownum,empno,ename,job,sal having rownum=2;
 
Is This Answer Correct ?    7 Yes 10 No
Lakshminarayana Reddy
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 9
select a.sal
from (
select sal ,rownum no
from (
select distinct sal
from emp
order by sal desc
)
) a
where a.no=2
 
Is This Answer Correct ?    15 Yes 5 No
Khandu Shinde
 
  Re: Write a query to get 2nd maximum salary in an employee table ?
Answer
# 10
The best answer should be the first one, this is because
the sql statement accesses table emp only once.
 
Is This Answer Correct ?    9 Yes 6 No
Wei
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
how to delete duplicate rows from a specified table(only single table) how do you know which join is need to be used UST 11
suppose we have a table in which 200 rows. i want to find 101 row ? what the query.... and how we find 4th and 5th highest salary and 1 to 10 highest salary   7
what is inline view?   15
what is difference between procedure and function, procedure and trigger? iFlex 7
real time applications of nullif?   3
What is difference between TRUNCATE & DELETE? TCS 14
What does “select count(1) from tab” result? IBM 9
Explain Connect by Prior?   2
How to find string or key value using pl/sql code? Ramco 2
Delete the emps whose salaries are lowest sals of their own dept.   5
What does “select count(*) from tab” result? IBM 14
How can I pass the inner procedure value to outer procedure ?   2
 
For more SQL PLSQL Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright © 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com