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
Explain the difference between rename and alias?
What is application trigger?
What schema means?
what is foreign key? : Sql dba
What is difference between sql and oracle?
What will you get by the cursor attribute sql%found?
What are the basic techniques of indexing?
What is trigger and stored procedure in sql?
Can we change the table name in sql?
what is recursive stored procedure? : Sql dba
Is it possible to sort a column using a column alias?
Which column of the user triggers data dictionary view displays the database event that will fire the trigger?
What is left inner join in sql?
Can we use pl sql in sql server?
Do ddl statements need commit?