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 (2038)
 SQL Server interview questions  SQL Server Interview Questions (1078)
 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
 
Can a view be updated/inserted/deleted?If Yes under what conditions?   3
State the advatage and disadvantage of Cursor's?   2
there is A table and B table in A table there 5 rows and in b table there are 2 rows i am firing query select * from a,b what will be the output? Cognizent 7
1> how are u debugging in plsql ? 2> how to connect oracle database from unix. is there ne way other than using sqlplus ?   2
What is difference between triggers and stored procedures. And advantages of SP over triggers ? TCS 4
What is the difference between DELETE and TRUNCATE? Tech-Mahindra 15
If the base table structure is changed what will happen to join index????   2
What is materialised View? IBM 1
can we call a procedure from a function? Mind-Tree 8
How to recompile a already made trigger?   2
what are the forced views Hexaware 5
what is the output of this query selet * from employee where 1=2 ??   11
 
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