how to find the second highest salary from emp table?

Answers were Sorted based on User's Feedback



how to find the second highest salary from emp table?..

Answer / velmurugan p

Select min(sal) from table_name where sal in(Select top 2 sal from table_name)

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / karthik.k

select max(salary) as second_highest from emp where salary
< (select max(salary) from emp)

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / pramod sharma

select f_name max(salary)from emp,dep
where salary<(select max(salary)from emp)

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / satish kumar

Select Top1 salary
from(select Distinct Top2 salary from employee order by salary DESC) a order by salary

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / rajkumar

SELECT * FROM TABLE WHERE columnName =
(SELECT MAX(column_name) FROM TABLE WHERE
column_name<(SELECT max(column_name) FROM TABLE))

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / mangesh pardhi

SELECT salary
FROM employee e
WHERE 2=(SELECT COUNT(DISTINCT salary)
FROM employees
WHERE e.salary<=salary)
--replace the number with 2,3,4 u wil find the that position
salary

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / kishan singh chilwal

SELECT MAX(sal)
FROM emp
WHERE sal <> (SELECT MAX(sal) FROM emp);

<> = not equal to
the SELECT statement in the WHERE clause will find the 1st max sal in the table
the 1st SELECT statement will find max sal in the table after excluding the first max sal

(ALTERNATE WAY)

SELECT MAX(sal)
FROM emp
WHERE sal not in (select max(sal) from emp );

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / syed hussain

select min(salary) from tbl_emp where salary in
(select top 4 salary from Tbl_emp order by salary desc)

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / hima

select sal from emp order by salary desc limit 1,1

Is This Answer Correct ?    0 Yes 0 No

how to find the second highest salary from emp table?..

Answer / subahar

SELECT MAX(average) AS Expr1
FROM sp
WHERE (average NOT IN
(SELECT MAX(average) AS Expr1
FROM sp AS sp_1))

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

how would you get the current date in mysql? : Sql dba

0 Answers  


what are the types of join and explain each? : Sql dba

0 Answers  


how to remove records from table? no name 1 a 2 b 1 a 2 b 3 c

8 Answers   Oracle,


What are the ddl commands?

0 Answers  


what are the types of subquery? : Sql dba

0 Answers  






ERROR:Insert or update on table"accnt" violates foreign key constraints "acct_to_curr_symbol" DETAILS:KEY(accnt_curr_id)(-2)is not present in the table "curr_symbol" ......solve The Problem..

0 Answers   Wipro,


What are the types of views in sql?

0 Answers  


What is sql injection owasp?

0 Answers  


Can we join same table in sql?

0 Answers  


What is acid property in a database?

0 Answers  


what are the limitations of mysql in comparison of oracle? Mysql vs. Oracle. : Sql dba

0 Answers  


How to execute OS(operating system) command from pl/sql?

3 Answers  


Categories