본문 바로가기
SQL/오라클(Oracle)

RANK() 함수

by SSaMKJ 2013. 3. 25.
오라클 정리

RANK() 함수
partition by 그룹 order by 정렬 대상

select department_id, score,
rank() over(partition by department_id order by score) rnk
from
(select 'a' department_id, 10 score from dual
union all
select 'b' department_id, 20 score from dual
union all
select 'a' department_id, 30 score from dual
union all
select 'b' department_id, 15 score from dual
union all
select 'a' department_id, 50 score from dual
union all
select 'b' department_id, 40 score from dual
)

댓글