Query to get max and second max in oracle in one query ?
Answer Posted / ajit
select max(sal),1 no
from emp
union
select sal,rn from (select sal,rownum rn from emp)
where rn = 2
order by 1 desc;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Why cursor variables are easier to use than cursors?
15. Display the item_cost and then truncate it to the nearest hundred, ten, unit, tenth and hundredth.
In the oracle version 9.3.0.5.0, what does each number shows?
How to call a stored function with parameters?
What is a database table in oracle?
Is there a combination of "like" and "in" in sql?
How to create a stored function in oracle?
What is format trigger?
WHEN CURSOR MOVES FROM ONE FORM TO ANOTHER FORM, HOW MANY TRIGGER WILL BE FIRED AND WHAT ARE THEIR SEQUENCE?
How to lock and unlock a user account in oracle?
What is partitioned table in Oracle?
1) Does oracle have any table which contain all the exceptions and it's code internally?
Explain the use of control file?
How to check database size in Oracle?
How to use subqueries with the in operator using oracle?