[今日のクエリ]RANK


SELECT ENAME, JOB, SAL, RANK() OVER (ORDER BY SAL DESC) 순위
	FROM EMP
    WHERE JOB IN ('ANALYST', 'MANAGER');

出力結果


ENAME|JOB|SAL|ランキング
FORD | ANALYST | 3000 | 1
SCOTT | ANALYST | 3000 | 1
JONES | MANAGER | 2975 | 3
BLANK | MANAGER | 2850 | 4
CLARK | MANAGER | 2450 | 5
SELECT ENAME, JOB, SAL, 
	   RANK() OVER (PARTITION BY JOB ORDER BY SAL DESC) AS 순위
	FROM EMP

出力結果


ENAME|JOB|SAL|ランキング
FORD | ANALYST | 3000 | 1
SCOTT | ANALYST | 3000 | 1
MILLER | CLERK | 1300 | 1
ADAMS | CLERK | 1100 | 2
JAMES | CLERK | 950 | 3
SMITH | CLERK | 800 | 4
JONES | MANAGER | 2975 | 1
BLANK | MANAGER | 2850 | 2
CLARK | MANAGER | 2450 | 3