how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / bibin__edappal
select salary from empTable where salary = (select
max(salary )from empTable where salary < (select max(salary
) from empTable))
OR
select salary from empTable where salary = (select
max(salary )from empTable where salary NOT IN (select
max(salary ) from empTable))
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / chandu
select max(sal)from table name where sal<(select max sal
from table name)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rajat
select max(sal) from table_name sal<(select max(sal)
from table_name)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / abhi
select max(sal)from emp where sal <> (select max(sal)from emp)
OR
select max(sal)from emp where sal < (select max(sal)from emp)
OR
select max(sal)from emp where sal != (select max(sal)from emp)
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / rajiv singh
select max(department_id) from departments where
department_id <(select max(department_id) from departments);
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / harish
select max(sal) from
emp where sal <(select max(sal) from emp)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / hari chaudhary
All My friend use this query then good result of your sql
database find in second or Third last data find.....
Select distinct(salary) From employee E1 Where
(n-1) = (Select Count(Distinct(E2.salary)) From employee E2
Where E2.salary > E1.salary)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / jitendra kumar
select salary from (select salary from emp ordery by salary
(dese) where rownum>=2;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / subrat
SELECT MAX(Sal) FROM EMP WHERE Sal < (SELECT MAX(Sal) FROM EMP)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sagar
if the salary is simple non-duplicate salary, you can use
the below queries:
select max(sal) from emp where sal != (select max(sal) from emp)
you can also try
select sal from (select * from emp order by sal desc) where
rownum = 2
| Is This Answer Correct ? | 0 Yes | 0 No |
What is not null in sql?
What operators deal with null?
Where is sql database stored?
what is csv? : Sql dba
Mention what does plv msg allows you to do?
What is scalar and vector?
What is vector point function?
how to get @@error and @@rowcount at the same time? : Sql dba
In what condition is it good to disable a trigger?
Is record in pl sql?
What is group by in sql?
What is clause in sql?
Oracle (3253)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)