Query to get max and second max in oracle in one query ?
Answer Posted / sumit wadhwa
select distinct(a.colname) from table a where &n=(select
count(distinct(b.colname)) from table b where
a.colname<=b.colname);
from this query u can find out Nth MAX in a one query
eg
select distinct(a.sal) from emp a where &n=(select count
(distinct(b.sal)) from emp b where a.sal<=b.sal);
| Is This Answer Correct ? | 55 Yes | 16 No |
Post New Answer View All Answers
What is the difference between post-database commit and post-form commit?
What is a cognitive schema?
Explain oracle left join with an example?
What is the fastest query method to fetch data from the table?
Which is better Oracle or MS SQL? Why?
What is the purpose of save points in oracle database?
How to use null as conditions in oracle?
How to assign values to data fields in record variables?
How to check the server version in oracle?
Hi friends can u send the oracle 9i full version download link?????????????? please reply ?
What is PL/SQL ?
I have a parent program and a child program. I want to write a statement in Exception Block of the parent program so that when the statement in the exception block is executed, the control goes to the next statement in the parent block bypassing the child block.How do i do that?
What is an oracle transaction?
You have 4 instances running on the same UNIX box. How can you determine which shared memory and semaphores are associated with which instance?
How can we delete duplicate rows in a table?