Query to get max and second max in oracle in one query ?
Answer Posted / lokanath
select * from emp a where 2 > (select count(distinct sal)
from emp b where b.sal > a.sal)
or else use Top Window functions (or) Analatical functions
select * from
(
select empno,ename,sal,rank() over (order by sal desc)
test from emp
)
where test <= 2
| Is This Answer Correct ? | 12 Yes | 4 No |
Post New Answer View All Answers
Which is better Oracle or MS SQL? Why?
How view is different from a table?
What is the fastest query method to fetch data from the table?
What is a user role in oracle?
Hi friends can u send the oracle 9i full version download link?????????????? please reply ?
What's dateware house and what's clustor with practicle example
21. Using a set operator, display the client number of all clients who have ever placed an order and whose whose name does not contain the string Sm.
What is connection pool in oracle?
How to divide query output into groups in oracle?
How to define and use table alias names in oracle?
Can we insert data in view oracle?
How to specify default values in insert statement using oracle?
How to store pictures on to the database?
Whats the benefit of dbms_stats over analyze?
What is the difference between "as" and "is" in an oracle stored procedure?