Query to get max and second max in oracle in one query ?
Answer Posted / sumit wadhwa
for max
select a.sal
from emp a
where 1=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal);
for second max
select a.sal
from emp a
where 2=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal)
| Is This Answer Correct ? | 33 Yes | 11 No |
Post New Answer View All Answers
What is a data dictionary and how can it be created?
How to get execution path reports on query statements?
Is it possible to center an object horizontally in a repeating frame that has a variable horizontal size ?
What is the difference between "as" and "is" in an oracle stored procedure?
Explain about achiever in sql?
How to convert csv to table in oracle?
Explain self joins in oracle?
How to use select statement to count the number of rows in oracle?
What are the four Oracle system processes that must always be up and running for the database to be useable?
How to define a variable to match a table column data type?
Does oracle charge for java?
What are the general rules on data consistency?
Please explain compound trigger in oracle?
There are n numbers of flatfile of exactly same format are placed in a folder.Can we load these flatfile's data one by one to a single relational table by a single session??
How do I find the database name in oracle?