Query to get max and second max in oracle in one query ?
Answer Posted / sunil
select sal from (select dense_rank() over(order by sal) rank
from emp) where rank in(1,2);
In above query you will get both highest and second highest
salary details even there are more people who are getting
highest and second highest salary.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is oracle a relational database?
Explain the use of record option in exp command.
Can you assign multiple query result rows to a variable?
What are the varoius components of physical database structure of oracle database?
What is a database table in oracle?
What is the parameter mode that can be passed to a procedure?
Select all the employees who were hired in last 2 years and who works in dept where max managers are working.
What do you understand by a database object?
How to establish administrator authentication to the server?
How to create a stored program unit?
Can u please explain me the Discussion on Except ,using cast like type cast. Question in the context of difference between two tables
Why do I get unexpected characters from 8-bit character sets in weblogic jdriver for oracle?
How to build data dictionary view an new database?
How to retrieve data from an cursor to a record?
What is user managed backup in Oracle?