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 (774)
 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
 
how to sort records in sql?   3
Practice 1: Changes to data will only be allowed on tables during normal office hours of 8.45 in the morning until 5.30 in the afternoon, MONDAY through FRIDAY. A. Create a procedure called SECURE_DML that prevents the DML statement from executing outside of normal office hours, returning the message: “you may only make changes during normal office hours” b. Create a statement trigger on the PRODUCT table which calls the above procedure. c. Test it by inserting a new record in the PRODUCT table. Tech-Mahindra 1
how do you count the duplicate records in a table Tech-Mahindra 9
what are pl/sql collections? JPMorgan-Chase 4
What is Difference between StoredProcedure and function?   3
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
How do you retrieve the last N records from a table?   8
Write one update command to update seqno field of a table on the basis of row number. HCL 3
one of the column in my table contains the data like SAL ---- 1000 1000 2000 3000 3000 So my requirement is i want output like SAL --- 1000 2000 3000 it mean i want to delete duplicate rows only how should u write query? TCS 8
Types of joins ? Digital-GlobalSoft 3
what is the different between unique+not null & primary key,   4
difference between pl/sql table and normal pl/sql table   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