Query to get max and second max in oracle in one query ?
Answer Posted / sumit wadhwa
for max
select a.sal
from emp a
where 1=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal);
for second max
select a.sal
from emp a
where 2=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal)
| Is This Answer Correct ? | 33 Yes | 11 No |
Post New Answer View All Answers
What is an oracle transaction?
What is sharded cluster?
what is Single Byte Overhead...?
What is Undo Management Advisor in Oracle?
what is the difference between restoring and recovering?
What are the different types of modules in oracle forms?
How to create additional tablespaces for an new database?
Is oracle a relational database?
How to use windows user to connect to the server?
Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracles. What database recovery options are available? Database is in archive log mode.
What happens to the current transaction if a ddl statement is executed?
What are the common oracle dba tasks?
How to sort output in descending order in oracle?
How to fetch the row which has the max value for a column?
Explain the use of grant option in imp command.