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 (2040)
 SQL Server interview questions  SQL Server Interview Questions (1080)
 MS Access interview questions  MS Access Interview Questions (25)
 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 (775)
 Databases AllOther interview questions  Databases AllOther Interview Questions (107)
Question
Write a query to get 2nd maximum salary in an employee table ?
 Question Submitted By :: SQL-PLSQL
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
select max(sal) from emp where sal<(select max(sal) from
emp))
 
Is This Answer Correct ?    189 Yes 36 No
M
 
Answer
# 2
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
 
 
 
Answer
# 3
select * from emp a where 2=(select count(distinct sal)
from emp b where a.sal<=b.sal)
 
Is This Answer Correct ?    41 Yes 8 No
Anil_abbireddy
 
Answer
# 4
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
 
Answer
# 5
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 ?    62 Yes 45 No
Sohail
 
Answer
# 6
select max(sal) from emp where sal<(select max(sal) from
emp);
 
Is This Answer Correct ?    15 Yes 4 No
Venkat
 
Answer
# 7
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
 
Answer
# 8
Select Max(Sal)
From Emp E
Where E.Sal < (Select Max(Sal) From Emp)
 
Is This Answer Correct ?    8 Yes 1 No
Abhay
 
Answer
# 9
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
 
Answer
# 10
Hi friends i think it is surely work because i worked for this.

select * from emp e where 1=(select count(distinct d.esal)
from emp d where d.esal>e.esal)

any one plz try if it's not work

plz let me know.
uday_testing@yahoo.co.in
 
Is This Answer Correct ?    6 Yes 3 No
Uday
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
How can I pass the inner procedure value to outer procedure ?   2
using subquery how can i calculate working days in a month? Spice-Telecom 2
Difference between SUBSTR and INSTR?   3
i have a word ***********hello********world******. I require a o/p **********hello world**********, Need to delete the middle stars.   3
Types of indexes. What is the default key created when a primary key is created in a table ? TCS 5
How to execute multiple sql statements in a single annonymous block irrespective of the sql statement result?   2
How do you get all records from 2 tables. Which join do you use? Microsoft 8
What is clustered, non-clustured and unique index. How many indexes can be created on a table ? TCS 3
Write a query to genarate target column.Please answer me. Advance Thanks. Src Tgt Q10 Quarter to 2010 Q90 Quarter to 1990 Q80 Quarter to 1980 Q74 Quarter to 1974 Infosys 2
When would you denormalize? Microsoft 8
Initially question was asked to mention the types of indexes. Then asked about BITMAP INDEX and B-Tree Index Polaris 2
Give an example of Full Outer Join? IBM 1
 
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