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 (775)
 Databases AllOther interview questions  Databases AllOther Interview Questions (106)
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 ?    1025 Yes 122 No
Winnie
 
Answer
# 2
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
 
Is This Answer Correct ?    708 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 ?    400 Yes 55 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 ?    481 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 103 No
Nalini
 
Answer
# 6
select max(sal) from emp where sal < (select max(sal) from
emp)
 
Is This Answer Correct ?    79 Yes 13 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 ?    26 Yes 3 No
Anuj Maheshwari
 
Answer
# 8
SELECT MAX(sal) from emp a where &n=(select COUNT(DISTINCT
(SAL)) from emp b where a.sal<=b.sal)
 
Is This Answer Correct ?    33 Yes 20 No
Erp_guns
 
Answer
# 9
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 ?    33 Yes 20 No
Radha Sri Seshu
 
Answer
# 10
select max(salary) from table01
where salary <(select max salary from table01)

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

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
What is the fastest way of accessing a row in a table? TCS 4
table :- city name country code abc 11 bcd 22 cde 232 def 33 write a procedure , so that when we give a phone no. eg - 1123456789 - o/p sud be city name = abc if phone no. - 2322345897 , o/p sud be =cde note - bcd and cde city name sud be diff. as dey diff only with th last no. Pls ans. this questnion.   1
What are the advantages of VIEW?   5
Types of optimization? Microsoft 6
What is differance unique key and primary key. EDS 7
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 in the table permanently and i want output in the above formatow should u write query? Cap-Gemini 11
Write a query to get 2nd maximum salary in an employee table ? TCS 61
pl/sql testing means what ...... explain process how to find pl/sql bugs Zensar 1
what is purge command explain about oracle performance tuning Accenture 2
How to maintain the history of code changes of pl/sql?   2
how to achieve this problem?i am having table with two colums like empno,gender. in gender column, i am having records male,female like that .my final output will be male female 5 6 Hexaware 4
what is meant by DML? HCL 5
 
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