일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- java
- JSTL
- 전자정부 표준프레임워크
- 한글
- 호환성
- Oracle
- 네이버스마트 에디터
- DB
- html
- 이클립스
- 날짜
- json
- 톰캣
- RADIO
- exception
- php
- MYSQL
- HTML5
- 문자열
- 스크립트
- null
- spring form tag
- jquery
- 웹 플랫폼 설치 관리자
- SSL
- maven
- checbox
- switch
- @RequestBody
- 오라클
- Today
- Total
개인적인 정리
[Oracle] RANK() 본문
오라클 RANK()
RANK()
-
RANK(expr) WITHIN GROUP (ORDER BY expr DESC|ASC NULLS FIRST|LAST)
RANK() OVER (query_partition_clause order_by_clause)
의 형태
RANK calculates the rank of a value in a group of values. The return type is NUMBER.
Rows with equal values for the ranking criteria receive the same rank. Oracle Database then adds the number of tied rows to the tied rank to calculate the next rank. Therefore, the ranks may not be consecutive numbers. This function is useful for top-N and bottom-N reporting.
- As an aggregate function, RANK calculates the rank of a hypothetical row identified by the arguments of the function with respect to a given sort specificaltin. The arguments of the function must all evaluate to constant expression within each aggregate group, because the identify a single row within each group. The constant argument expressions and the expressions in the ORDER BY clause of the aggregate match by position. Therefore, the number of arguments must be the same and their types must be compatible.
- As an analytic function, RANK computes the rank of each row returned from a query with respect to the other rows returned by the query, based on the values of the value_exprs in the order_by_clause.
오라클 oe 계정 또는 hr 계정으로 테스트가 가능.
SQL>
SELECT
RANK(15500, 0.05) WITHIN GROUP (ORDER BY salary, commission_pct) "Rank"
FROM employees ;
--> 105
SQL> SELECT
RANK(15500) WITHIN GROUP (ORDER BY salary) "Rank"
FROM employees ;
--> 105
SQL>
SELECT
department_id,
last_name,
salary,
RANK() OVER (PARTITION BY department_id ORDER BY salary) RANK
FROM employees
WHERE department_id =60
ORDER BY RANK, last_name ;
;
DENSE_RANK 와 조금 다르다
https://web-obj.tistory.com/389
'DB > ORACLE' 카테고리의 다른 글
[Oracle] REGEXP_INSTR() (0) | 2020.04.21 |
---|---|
[ORACLE] REGEXP_COUNT() (0) | 2020.04.21 |
[Oracle] RAWTOHEX() (0) | 2020.04.14 |
[Oracle]RATIO_TO_REPORT() (0) | 2020.04.14 |
[Oracle] POWER() (0) | 2020.04.14 |
[Oracle] PERCENT_RANK() (0) | 2020.04.14 |
[Oracle]NVL2() (0) | 2020.04.13 |
[Oracle] NVL() (0) | 2020.04.13 |