:: 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                      
Categories >> Software >> Databases >> SQL PLSQL


 Oracle interview questions  Oracle Interview Questions (2041)
 SQL Server interview questions  SQL Server Interview Questions (1082)
 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 (54)
 SQL PLSQL interview questions  SQL PLSQL Interview Questions (775)
 Databases AllOther interview questions  Databases AllOther Interview Questions (107)
how to find the second highest salary from emp table?
 Question Submitted By :: SQL-PLSQL
I also faced this Question!!     Answer Posted By  
# 1
select max(sal) from emp
where sal not in (select max(sal) from emp )
Is This Answer Correct ?    1038 Yes 122 No
# 2
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
Is This Answer Correct ?    718 Yes 92 No
# 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 ?    403 Yes 56 No
# 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 ?    483 Yes 262 No
Gourvendra Singh
# 5
Follow the following Query, You get the second highest
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 ?    203 Yes 104 No
# 6
select max(sal) from emp where sal < (select max(sal) from
Is This Answer Correct ?    81 Yes 14 No
Muhammed Zaheer
# 7
select sal from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp));
Is This Answer Correct ?    30 Yes 4 No
Anuj Maheshwari
# 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 ?    34 Yes 21 No
# 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 ?    34 Yes 21 No
Radha Sri Seshu
# 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
What is INSTEAD OF trigger ? TCS 13
wa procedure to return the month and the no'f developers joined in each month. Fidelity 2
Display the total debit counts, total credit counts, sum of total debits, sum of total credits from an employee's transaction table (a single table) containing the following columns. Transaction_number Transaction_amount Transaction_date Transaction_type --> tells if the amount is a credit or a debit. As the query alone is important, the table is left with specifying just the field's name. Pls help me with this query. iNautix 3
What is clustered and non-clustered indexes? Microsoft 4
What packages(if any) has oracle provided for use by developers?   1
write a procedure to find top second no from a list of numbers ABC 1
Explain the two type of Cursors ? Hi-Caliber-IT 8
wirte a query to remove null? following table are col1 col2 col3 dinesh null null null suresh null null null prakesh i want the output like col1 col2 col3 dinesh suresh prkaesh TCS 5
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 is mutating trigger?How to avoid it?? Tech-Mahindra 3
full outer join syntax   5
For more SQL PLSQL Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright 2013  All Rights Reserved.   ::