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
Can we create database in oracle using command line ?
What are the differences between char and nchar in oracle?
Explain a segment?
What happens to the indexes if a table is recovered?
How to lock and unlock a user account in oracle?
What operating systems are supported by oracle database 10g xe?
what is the difference between data migration and production migration.
Assuming today is Monday, how would you use the DBMS_JOB package to schedule the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run subsequently every other day at 2AM.
How to rename a tablespace in oracle?
How can I get column names from a table in oracle?
Why do you create or replace procedures rather that drop and recreate.
what is IDE,DMV in sql server?
How can we delete duplicate rows in a table?
Why cursor variables are easier to use than cursors?
How to store only time; not date and time?