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
How many types of segments in Oracle?
Explain the use of log option in exp command.
Why do we need oracle client?
How to create a new table by selecting rows from another table?
How to assign query results to variables?
What is an oracle tablespace?
What are the most common interview questions on ETL Testing for experience?
What will be the syntax to find current date and time in format "yyyy-mm-dd"?
How to establish administrator authentication to the server?
What to do if the startbd.bat failed to start the xe instance?
What is the relationship among database, tablespace and data file?
How to update values in a table in oracle?
How to install oracle database 10g xe?
What is the relation of a user account and a schema in oracle?
What is the difference between count (*), count (expression), count (distinct expression)?