Find Nth Highest row from the table in ORACLE

In this example N=6

select bo_id_cust,count(1) from ps_rc_Case
where creation_date>'19-OCT-08'
group by bo_id_cust
HAVING COUNT(1)
IN (
SELECT A.COL3 FROM (
select bo_id_cust,count(1) COL3 from ps_rc_Case
where creation_date>'19-OCT-08'
group by bo_id_cust
HAVING COUNT(1)>1
) A
WHERE 6 =
( SELECT COUNT(DISTINCT B.COL3)
FROM (
select bo_id_cust,count(1) COL3 from ps_rc_Case
where creation_date>'19-OCT-08'
group by bo_id_cust
HAVING COUNT(1)>1 ) B
WHERE B.COL3>=A.COL3 )
)

No comments:

Post a Comment