일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 이클립스
- JSTL
- MYSQL
- DB
- HTML5
- 한글
- jquery
- 톰캣
- 네이버스마트 에디터
- 전자정부 표준프레임워크
- 날짜
- SSL
- RADIO
- html
- Oracle
- exception
- 호환성
- json
- checbox
- spring form tag
- null
- 오라클
- 문자열
- maven
- 웹 플랫폼 설치 관리자
- java
- @RequestBody
- php
- 스크립트
- switch
- Today
- Total
개인적인 정리
[Oracle]ROW_NUMBER() 본문
오라클 ROW_NUMBER()
ROW_NUMBER()
-
ROW_NUMBER() OVER (query_partition_clause order_by_clause)
의 형태
ROW_NUMBER is an analytic function. It assigns a unique number to each row to which it is applied (either each row in the partition or each row returned by the query), in the ordered sequence of rows specified in the order_by_clause, beginning with 1.
By nesting a subquery using ROW_NUMBER inside a query that retrieves the ROW_NUMBER values for a specified range, you can find a precise subset of rows from the results of the inner query. This use of the function lets you implement top-N, bottom-N, and inner-N reporting. For consistent results, the query must ensure a deterministic sort order.
You cannot nets analytic functions by using ROW_NUMBER or any other analytic function for expr. However, you can use other built-in function expression for expr.
오라클 oe 계정, hr 계정으로 테스트 가능
SQL>
SELECT department_id, first_name, last_name, salary, rn
FROM (
SELECT
department_id, first_name, last_name, salary,
ROW_NUMBER() OVER(PARTITION BY department_id ORDER BY salary desc) rn
FROM employees
)
WHERE RN <=3
ORDER BY department_id, salary DESC, last_name
;
'DB > ORACLE' 카테고리의 다른 글
[ORACLE] NULL 치환 - NVL (0) | 2021.07.28 |
---|---|
오라클 컬럼 이름 변경 (0) | 2021.02.19 |
[Oracle]RTRIM() (0) | 2020.06.11 |
[Oracle]RPAD() (0) | 2020.06.11 |
[Oracle]ROUND(number) (0) | 2020.06.10 |
[Oracle]ROUND(date) (0) | 2020.06.10 |
[Oracle]REPLACE() (0) | 2020.06.10 |
[Oracle]REMAINDER() (0) | 2020.06.10 |