Ok, head hurts, been long day -- this is as far as I've gotten it, say you wanted 95th percentile:
ops$tkyte@ORA10G>
ops$tkyte@ORA10G> select distinct deptno,
2 max( case when rn/cnt <= 0.95 then rn/cnt end ) over ( partition by deptno ) min_rncnt,
3 max( case when rn/cnt <= 0.95 then sal end ) over ( partition by deptno ) min_sal,
4 min( case when rn/cnt >= 0.95 then rn/cnt end ) over ( partition by deptno ) max_rncnt,
5 min( case when rn/cnt >= 0.95 then sal end ) over ( partition by deptno ) max_sal
6 from (
7 select deptno,
8 sal,
9 count(*) over (partition by deptno) cnt,
10 row_number() over(partition by deptno order by sal) rn
11 from emp
12 )
13 /
DEPTNO MIN_RNCNT MIN_SAL MAX_RNCNT MAX_SAL
---------- ---------- ---------- ---------- ----------
10 .666666667 2450 1 5000
20 .8 3000 1 7781.24
30 .833333333 1600 1 2850
that gives you by each deptno, the row(s) that are closest to 0.95 -- one below and one above (or just the one row if that applies).
Somewhere between 2450 and 5000 is your value for deptno 10 (and so on) :)
somewhere between.... I'll let someone who knows how to calculate a percentile take it from here :)