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 / neetika vardhan

SELECT MAX(sal)
FROM EMP WHERE sal NOT IN (SELECT MAX(sal) FROM emp)

Is This Answer Correct ?    42 Yes 3 No

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

Answer / ramya p

SELECT DISTINCT (sal),deptno FROM emp a
WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM emp b
WHERE a.sal<=b.sal)

N is the Nth highest salary you want to print. In this case
N=2

Is This Answer Correct ?    7 Yes 1 No

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

Answer / hari krishna j

SELECT A.SAL FROM EMP_TAB A
WHERE 1=(SELECT COUNT(*) FROM EMP_TAB B
WHERE B.SAL > A.SAL)

Change value of 1 if
0 - First heighest sal
1 - Second " "
2 - Third heighest sal
.
.
.

Is This Answer Correct ?    5 Yes 0 No

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

Answer / udhayakumar

select salary from (select salary from emp order by salary
desc) where rownum=2;

Is This Answer Correct ?    3 Yes 2 No

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

Answer / eshwer

Try this
select * from (SELECT empno,sal, DENSE_RANK() OVER (ORDER BY sal desc) AS SalRnk
FROM scott.emp) where salrnk=2;

Is This Answer Correct ?    1 Yes 0 No

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

Answer / vinayak jamdar

Select top 1 empid,salary from (select distinct top 2
empid,salary from emp order by salary desc)a order by salary

Is This Answer Correct ?    1 Yes 1 No

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

Answer / sunilpanghal

select rownum as rowid,salary from (salary from employees
oderby salary )where rownum <2

Is This Answer Correct ?    1 Yes 1 No

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

Answer / sachin s. patil

SELECT * FROM
(SELECT ROWNUM DD, M.* FROM
(SELECT SAL FROM EMP order by sal desc )M)
WHERE DD=2

Is This Answer Correct ?    1 Yes 1 No

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

Answer / lalit

select name, sal from (select name,sal from emp where sal<(select max(sal) from emp) order by sal desc)where rownum=1;

Is This Answer Correct ?    0 Yes 0 No

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

Answer / sachin s. patil

SELECT SAL FROM
(SELECT ROWNUM DD, M.* FROM
(SELECT SAL FROM EMP order by sal desc )M)
WHERE DD=2/***HERE U CAN ADD ANY NUMBER (WHERE I PUT 2)
, U WILL GET HEIGHEST SALARY THAT POSITION *******/

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

Explain isolation levels. : Transact sql

0 Answers  


which operator is used in query for pattern matching? : Sql dba

0 Answers  


can we delete the trigger in a view? if yes why if not why?

5 Answers   Tech Mahindra,


i have a column which may contain this kind of value: 123*67_80,12*8889_5,34*8_874 ,12*7_7 (can contain space before a comma, and this string length can be anything) now i want to split this value into two column like: column1: 123*67,12*8889,34*8,12*7 column2: 80,5,874,7 use function for this

0 Answers  


How do I find duplicates in two columns?

0 Answers  






Why we use cross join?

0 Answers  


what are the t string functions available in tsql? : Transact sql

0 Answers  


is it possible to pass an object or table to a procedure as an argument?

0 Answers  


What is function and procedure?

0 Answers  


Can we use views in stored procedure?

0 Answers  


What are the differences between Database Trigger and Integrity constraints ?

4 Answers  


which will fire first ? Trigger or Constraint

24 Answers   i2, IBM,


Categories