Query to get max and second max in oracle in one query ?
Answer Posted / vaibhav
SELECT Sal
FROM (Select Sal from Emp_Salary order by Sal desc)
WHERE rownum < =2;
Above query will fetch two rows. First row is the max salary
and second row second max.
IF we only need to find second max, then
SELECT Min(Sal)
FROM (Select Sal from Emp_Salary order by Sal desc)
WHERE rownum < =2;
| Is This Answer Correct ? | 4 Yes | 3 No |
Post New Answer View All Answers
I just want to maintain data like an employee can belongs to 3 or more departments . We can resolve this by using composite key but it avoids normalization rules. So Can anyone tell me how can I maintain data.
 What are the oracle DML commands possible through an update strategy?
What is oracle latest version?
How to use "in out" parameter properly?
What are the system predefined user roles?
What is program global area (pga) in oracle?
In which language oracle has been developed?
How to connect to the server with user account: sys?
Who developed oracle & when?
How do I start tns listener?
Calculate difference between 2 date / times in oracle sql?
What is oracle data type?
How do I find the database name in oracle?
How to check your oracle database 10g xe installation?
How to set a transaction to be read only in oracle?