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
how to find the second highest salary from emp table?
 Question Submitted By :: SQL-PLSQL
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
select max(sal) from emp
where sal not in (select max(sal) from emp )
 
Is This Answer Correct ?    1029 Yes 122 No
Winnie
 
Answer
# 2
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
 
Is This Answer Correct ?    711 Yes 90 No
Gayathri
 
 
 
Answer
# 3
use this query. it works great.

select max(sal) from table_name where sal<(select max(sal)
from table_name)
 
Is This Answer Correct ?    401 Yes 56 No
Bipin
 
Answer
# 4
Please put the below query, u will get the second highest
salary of the table :---

select sal from(select sal from
(select distinct sal from emp order by sal desc)
where rownum<=2 order by sal asc)
where rownum=1;
 
Is This Answer Correct ?    482 Yes 260 No
Gourvendra Singh
 
Answer
# 5
Follow the following Query, You get the second highest
salary.
SQL> Select level,Max(sal) from emp
Where level=&level connect by prior sal>sal
group by level;
SQL> Enter the level No=2 (Here enter 2 manually)

Then you will get the 2nd highest salary.
If you want 3rd Highest salary, then enter level no=3.
 
Is This Answer Correct ?    202 Yes 104 No
Nalini
 
Answer
# 6
select max(sal) from emp where sal < (select max(sal) from
emp)
 
Is This Answer Correct ?    79 Yes 14 No
Muhammed Zaheer
 
Answer
# 7
select sal from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp));
 
Is This Answer Correct ?    27 Yes 4 No
Anuj Maheshwari
 
Answer
# 8
second method is
select sal from emp e1 where 2=(select count(distinct(sal))
from emp e2 where e1.sal<=e2.sal);
 
Is This Answer Correct ?    34 Yes 20 No
Radha Sri Seshu
 
Answer
# 9
SELECT MAX(sal) from emp a where &n=(select COUNT(DISTINCT
(SAL)) from emp b where a.sal<=b.sal)
 
Is This Answer Correct ?    34 Yes 21 No
Erp_guns
 
Answer
# 10
select max(salary) from table01
where salary <(select max salary from table01)

in mainframe env
 
Is This Answer Correct ?    25 Yes 12 No
Shiva Kumar
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
which will fire first ? Trigger or Constraint IBM 20
what are the advantages of package? iFlex 6
In a package if we have 10 procedures or functions,How to know which will execute first?   1
A table has 150 records. How do you retrieve 100th row to 120th row from that table ? IBM 16
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
what is the difference between trigger and constraint?   2
what is mean by forward declaration and where we'll use it. TCS 4
What is clustered, non-clustured and unique index. How many indexes can be created on a table ? TCS 3
Can we use SQL%ISOPEN in implicit cursors? Does this attribute works properly in Implicit Curosors?   3
what is the forward decleration in packages?   1
how to create a database in oracle?please gve anser with example   1
IN A TABLE HAVE ONE COLUMN PRIMARY KEY..IT WILL NOT ALLOWS NULL VALUES AND DUPLICATE VALUES..INSTEAD OF PRIMARY KEY WHY CANT WE USE UNIQUE AND NOT NULL.THESE TWO ALSO DOESNT ACCEPT NULL VALUES IN NOT NULL AND UNIQUE DOESNT ACCEPT DUPLICATE VALUES? SO WHAT IS THE DIFEERENCE BETWEEN(UNIQUE,NOT NULL) AND PRIMARY KEY?????? rsystems 7
 
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