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


Please Help Members By Posting Answers For Below Questions

Explain the difference between rename and alias?

545


What is application trigger?

548


What schema means?

529


what is foreign key? : Sql dba

589


What is difference between sql and oracle?

568






What will you get by the cursor attribute sql%found?

540


What are the basic techniques of indexing?

577


What is trigger and stored procedure in sql?

560


Can we change the table name in sql?

537


what is recursive stored procedure? : Sql dba

531


Is it possible to sort a column using a column alias?

609


Which column of the user triggers data dictionary view displays the database event that will fire the trigger?

598


What is left inner join in sql?

521


Can we use pl sql in sql server?

543


Do ddl statements need commit?

540