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 (2036)
 SQL Server interview questions  SQL Server Interview Questions (1076)
 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 (771)
 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 :: 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 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
# 7
select max(sal) from emp where sal<(select max(sal) from
emp);
 
Is This Answer Correct ?    14 Yes 4 No
Venkat
 
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
 
Delete the emps whose salaries are lowest sals of their own dept.   5
can we delete the trigger in a view? if yes why if not why? Tech-Mahindra 5
25.67,-1 Trunc = 20 Round= 30 HOW???? Karrox 2
how to calcuate the second highest salary of he employee Synechron 12
hi..........i m Accenture employee...Accenture is an IT company having itz branches in India at Mumbai, Pune,Delhi, Hyderabad, Chennai and Bangalore....Presently there are openings here for SAP, Testing, Oracle,Java,.NET,MAinframe and Peoplesoft...... I am a software engineer working with Accenture,Mumbai....u can mail me in your resume..i`ll forward it to our HR team...my mail id: pankit.lodaya@accenture.com Wipro 6
PL/SQL allocates memory for the variable's at runtime or at compile time   3
package specification-3 procedures package body-4 procedures how can i write for other procedure in package body Reliance 2
How to return multiple records from procedure?   2
what is sql profiler Fidelity 2
what is the command for user data type?   2
If the base table structure is changed what will happen to join index????   2
What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?   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