Created
October 21, 2013 02:09
-
-
Save springcome/7077699 to your computer and use it in GitHub Desktop.
rank(), oracle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- RANK | |
-- 순위를 정할때 같은값이 있을경우 같은 RANK값을 가지게 된다. | |
-- 다음 랭크는 중복된 값을 건너뛰게된다. | |
-- EX ) 1, 2, 2, 4, 4, 6 | |
SELECT MEMBER_ID, MEMBER_NAME, MEMBER_GROUP_CODE | |
, RANK() OVER (ORDER BY MEMBER_SEQ DESC) AS RANK | |
FROM MEMBER | |
-- DENSE_RANK | |
-- 순위를 정할때 같은값이 있을경우 같은 RANK값을 가지게 된다. | |
-- 다음 랭크에 중복상관없이 순차적으로 넘버링된다. | |
-- EX ) 1, 2, 2, 3, 4, 4, 5 | |
SELECT MEMBER_ID, MEMBER_NAME, MEMBER_GROUP_CODE | |
, RANK() OVER (ORDER BY MEMBER_SEQ DESC) AS RANK | |
FROM MEMBER | |
-- RANK GROUP | |
-- 그룹별로 순위를 부여한다 | |
-- EX ) 1, 2, 3, 1, 2, 3 | |
SELECT MEMBER_ID, MEMBER_NAME, MEMBER_GROUP_CODE | |
, RANK() OVER (PARTITION BY MEMBER_GROUP_CODE ORDER BY MEMBER_SEQ DESC) AS RANK | |
FROM MEMBER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment