Write a query to get 2nd maximum salary in an employee table ?
Answer Posted / mark berlin.
REM solution #1:
select * from(
select distinct nvl(salary,-1) as sal
from employees
where nvl(salary,-1) < (select max(nvl(salary,-1)) from
employees)
order by nvl(salary,-1) desc)
where rownum=1;
REM Solution #2
select * from (
select distinct salary from employees
order by salary
desc
)
where rownum < 3
minus
select * from (
select distinct salary from employees
order by salary
desc
)
where rownum =1;
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
how do you control the max size of a heap table? : Sql dba
What is varchar used for?
What is sql architecture?
What are character functions?
how to use in conditions? : Sql dba
What is the maximum size of sqlite database?
What is trigger and stored procedure in sql?
What are the advantages of indexing?
What does a pl/sql package consist of?
what are the limitations of identity column? : Transact sql
What is the use of stored procedures?
What are crud methods?
What is sorting in sql?
Why join is faster than subquery?
What is the difference between having clause and where clause?