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 raw datatype?
What is connection pool in oracle?
What is a sub query? Describe its types?
What does sharding mean?
How to pass parameters to procedures in oracle?
What is the difference between sharding and replication?
How to display employee records who gets more salary than the average salary in the department?
What is the difference between Delete, Truncate and Drop in Oracle?
Is oracle an operator?
How i can handle exception in large code like 1000 line without distrubing the code or without exception handler sction?
6. Display the client name and order date for all orders using the traditional method.
what is partitioning? Types of partitioning. explain? what is the new kind of partitioning type introduced in 9i?
What is the sql query to concatenate column values from multiple rows in oracle?
How a database is related to tablespaces?
What is SQL access advisor in Oracle?