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
Is it possible to create startup or shutdown trigger for on-schema?
How bulk collect improves performance?
What is assignment operator in pl sql?
why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba
What is online transaction processing (oltp)?
What is the difference between a subquery and a join?
What is tuple in sql?
What is the difference between distinct and unique in sql?
What is multiple partition?
What is pl/sql table? Why it is used?
What is transaction control language (tcl)?
What is trigger explain it?
What are basic techniques of indexing?
What is %type in sql?
what is the difference between sql and t-sql? : Transact sql