ALLInterview.com :: Home Page KalAajKal.com
 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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Databases  >>  SQL PLSQL
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
Write a query to find second highest salary of an employee.
 Question Submitted By :: Mreddy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 1
Use the below Query:

Select Max(salary) from Emp 
Where Max(salary) < (Select Max(salary) from emp
                     where emp-no=101);
 
Is This Answer Correct ?    6 Yes 12 No
Amol Londhe
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 2
select max(salary)
from Emp
where rownum < 2;
 
Is This Answer Correct ?    2 Yes 9 No
Jeff
 
 
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 3
select top 1 emp_total_sal,emp_name from (
select top 2 emp_total_sal,emp_name  from employee_table 
ORDER BY emp_total_sal DESC)  a
ORDER BY emp_total_sal ASC
 
Is This Answer Correct ?    2 Yes 2 No
Versaites
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 4
I write the query for this question using OLAP functions.

 select  e1.* from (select ename,sal,rank()
 over(order by sal desc) rank from emp) e1
 where e1.rank=2;
 
Is This Answer Correct ?    2 Yes 1 No
Gvmahesh
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 5
SELECT salary 
FROM (SELECT salary FROM emp
      ORDER BY DESC salary)
WHERE RowNum=2
 
Is This Answer Correct ?    1 Yes 7 No
Kitcat
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 6
to select the nth highest salary from emp table

select distinct(a.sal) from emp a where &n=
(select count(distinct(b.sal))from emp b where a.sal<=b.sal);
 
Is This Answer Correct ?    0 Yes 1 No
Manoranjan
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 7
select max(sal) from emp where sal<select max(sal) from emp
 
Is This Answer Correct ?    3 Yes 3 No
Monika
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 8
select max(sal) from Emp where sal < (select max(sal) from 
Emp)
 
Is This Answer Correct ?    5 Yes 0 No
Cooldude
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 9
select ename,salary from emp
where rownum=2
order by salary desc
 
Is This Answer Correct ?    0 Yes 3 No
Vamana Murthy
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 10
select ename,salary from (select rownum,ename,salary from 
emp
order by desc) where rownum=2;
 
Is This Answer Correct ?    0 Yes 0 No
Senorita
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 11
SELECT sal
FROM (SELECT sal FROM emp
      ORDER BY sal desc)
WHERE RowNum<=2
minus
SELECT sal
FROM (SELECT sal FROM emp
      ORDER BY sal desc)
WHERE RowNum<=1
 
Is This Answer Correct ?    3 Yes 0 No
Gautam Poonia
 
  Re: Write a query to find second highest salary of an employee.
Answer
# 12
select  e1.* from (select ename,sal,rank()
 over(order by sal) rank from emp) e1
 where e1.rank=2;
 
Is This Answer Correct ?    1 Yes 0 No
Sathish P
 

 
 
 
Other SQL PLSQL Interview Questions
 
  Question Asked @ Answers
 
What is an index and types of indexes. How many number of indexes can be used per table ? BirlaSoft6
why should required for Indexed by table in pl/sql  2
What is differance unique key and primary key. EDS6
Explain how procedures and functions are called in a PL/SQL block ?  2
Give the structure of the procedure ?  1
Can any one tell me how to increase the performance of a sql query ie what are the performance tips in creating or writing a sql query !!? eBay3
Explain UNION,MINUS,UNION ALL, INTERSECT?  1
write a query to delete similar records in different tables with same structure  4
How do you optimize SQL queries ? Infosys4
Delete duplicate records in the emp table.  5
What is integrity constraints? Ramco4
a procedure one in two out parameters i am waiting it in a sql query can i get the output  1
Write one update command to update seqno field of a table on the basis of row number. HCL3
What is PL/SQL table ?  3
How do you get all records from 2 tables. Which join do you use? Microsoft7
Hi, Can anybody please explain me the flow of the below query. I am not able to understand how this query works. This query is for finding the Nth highest salary.. SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal); If N = 2 then second highest salary will be the o/p. If N = 3 then third highest salary will be the o/p. and so on.. Thanks, Nitin Ness-Technologies4
how to connect oracle in unix prompt? Polaris3
Can a table have two primary keys? HCL25
How to maintain the history of code changes of pl/sql?  2
What is normalization and types of normalization? Microsoft5
 
For more SQL PLSQL Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com