:: 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 (2040)
 SQL Server interview questions  SQL Server Interview Questions (1080)
 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)
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 ?    1030 Yes 122 No
# 2
select max(salary ) from emp table where sal<(select max
(salary)from emp table)
Is This Answer Correct ?    712 Yes 90 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 ?    401 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 ?    482 Yes 260 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 ?    202 Yes 104 No
# 6
select max(sal) from emp where sal < (select max(sal) from
Is This Answer Correct ?    79 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 ?    27 Yes 4 No
Anuj Maheshwari
# 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
# 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
# 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
A table was given with 3 columns like Manager id,Manager Name and Employee name. Question was to create hierarchy. TCS 2
How to return multiple records from procedure?   2
using cursors salesman get bonus as 10% of their salary , managers get 20% , analalist get 30%. generae a report showing the employee name, salary , bonus. Fidelity 4
a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining. CGI 1
what are the forced views Hexaware 5
write a query filter the null value data following source? name age john 30 smith null null 24 sharp 35 i want output name age john 30 sharp 35 TCS 1
When the mutating error will comes? and how it will be resolved?   2
How do you optimize SQL queries ? Infosys 6
i have one table with accounts and amounts as colums.accounts with columns c and d. and amounts with values 1000,2000,3000 for c and 4000,5000,8000 for d.i need to find the sum of these accounts c and d individually and find the differences between their sum using one select statement. Hewitt 11
What is the differnce between view and materialized view TCS 4
what is the correct way of selection statement a. select/from/table_name/orderby/groupby/having b. select/from/table_name/groupby/having/orderby HCL 3
what is meant by tuning and tk proof?   2
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.   ::