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
Explain the difference between replace() and translate() functions in oracle?
What is the usage of merge statement?
Which is better Oracle or MS SQL? Why?
Name the various constraints used in oracle?
How to list all tables in your schema?
What are the oracle differences between nvl and coalesce
How do I connect to oracle?
What is java oracle used for?
What is a trigger and what are its types in oracle?
What are the numeric comparison operations?
What are the differences between char and nchar in oracle?
Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current date, changes the date format to include minutes & seconds, issues a drop table command, displays the date again, and finally exits.
What do database buffers contain?
Explain the use of file option in exp command.
What happens if recursive calls get out of control?