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
 
Give an example of any procedure. iFlex 5
i have a table with column sno with 30 records. i want to update this column by item by item in asp.net. i wantto enter new values into that from 1 to 30 how is it possible with backend c#   1
what is an associative array with example?   1
If a procedure within a package is invalidated whether the entire package will be invalid and has to be recompiled again? TCS 2
What are nested triggers ? TCS 6
what is HASH join? Genpact 2
what are the differences among these table level lock modes - IN SHARE MODE, IN SHARE UPDATE MODE, IN EXCLUSIVE MODE ? HCL 2
How do you retrieve set of records from database server. {Set max records = 100 & use paging where pager page no or records = 10 & after displaying 100 records again connect to database retrieve next 100 } DELL 2
State the advatage and disadvantage of Cursor's?   2
I have one table,in that table (1)i have java1.1 version books are 2 and java1.5 version books are 4. (2).Net2.0 books are 3, .Net3.5 books are 2 (3)ABC1.6 books are 4, ABC2.0 books are 3. Now i want output is like Book Count Java 6 .Net 5 ABC 7 For this i need sql query, please help me if anyone how to get this result. Thanks, Seenu Adea 4
write a query to delete similar records in same table TCS 13
what is External tables? explain with examples TCS 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