Hey Imran Sheikh,
This might help.
select dr rank, sal
from (
select sal,
row_number()over(partition by sal order by sal desc) rn,
dense_rank()over(order by sal desc) dr
from emp
)
where rn = 1 and dr <= 2
/
Please take a few minutes to provide feedback on the quality of service you received from our staff. The Department of Education values your feedback as a customer. Commissioner of Education Jeanine Blomberg is committed to continuously assessing and improving the level and quality of services provided to you.Simply use the link below. Thank you in advance for completing the survey.
http://data.fldoe.org/cs/default.cfm?staff=Ed.[Email address protected]
-----Original Message-----
From: Imran Sheikh
[mailto:oracledba-ezmlmshield-x29827903.[Email address protected]
Sent: Monday, April 30, 2007 7:02 AM
To: LazyDBA Discussion
Subject: max rows
Dear all,
Can I get two max rows in a query like:
Select max(col1)
From table1
Now if it returns 10 rows I want to get only 2 highest value rows.
Thanks,
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
Oracle LazyDBA home page