how to calcuate the second highest salary of he employee

Answers were Sorted based on User's Feedback



how to calcuate the second highest salary of he employee..

Answer / shailesh

select sal from emp where sal=(select max(sal) from emp
where sal<(select max(sal) from emp);

Is This Answer Correct ?    0 Yes 1 No

how to calcuate the second highest salary of he employee..

Answer / jitendra

To get nth highest Salary, use below query

SELECT TOP 1 salary
FROM (
SELECT TOP nth salary
FROM Emp
ORDER BY salary DESC
) TmpTable
ORDER BY salary ASC

Replace nth with your number like second highest=2 4th=4 etc

Is This Answer Correct ?    0 Yes 3 No

how to calcuate the second highest salary of he employee..

Answer / vivek ghorad

select min(select top(2)salary from emp)from emp;

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More SQL PLSQL Interview Questions

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.

3 Answers   iNautix, Oracle,


What is the size of partition table?

0 Answers  


What company owns postgresql?

0 Answers  


which command using query analyzer will give you the version of sql server and operating system? : Sql dba

0 Answers  


Can instead of triggers be used to fire once for each statement on a view?

0 Answers  






what is a cursor

9 Answers   IBM, TCS, Wipro,


what are the different type of sql's statements ? : Sql dba

0 Answers  


What is the syntax to add a record to a table?

0 Answers  


How bulk collect improves performance?

0 Answers  


What is mutating table?

11 Answers   Saama Tech,


table name: prod there are three fields in the table that are 1.proddate 2.prodQty 3.model Day wise prodQty is stored in the table prod write a query to display total prodqty in the year 2004 april.

2 Answers   Maruti Suzuki,


how can we know the count/number of elements of an array? : Sql dba

0 Answers  


Categories