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 can we destroy the cookie? : Sql dba
What is difference between inner join and self join?
Could you please provide oca (oracle 10g) dumps for my certification ?
How is use pl and sql?
Is a table valued function object?
what are the different type of sql's statements ? : Sql dba
What is data control language (dcl)?
Does sql support programming?
How do you select unique values in sql?
what is the use of set statement in tsql? : Transact sql
What is trigger in pl sql?
What are the sql versions?
What is sqlerrm?
how to create a new view in mysql? : Sql dba
How many primary keys can a table have?