-
105. MySQL - 윈도우 함수IT 공부방 [기본지식 정리]/데이터베이스 (DB) 2025. 3. 26. 17:22
1. 윈도우 함수 종류
Table 14.30 Window Functions
NameDescriptionCUME_DIST() Cumulative distribution value DENSE_RANK() Rank of current row within its partition, without gaps FIRST_VALUE() Value of argument from first row of window frame LAG() Value of argument from row lagging current row within partition LAST_VALUE() Value of argument from last row of window frame LEAD() Value of argument from row leading current row within partition NTH_VALUE() Value of argument from N-th row of window frame NTILE() Bucket number of current row within its partition. PERCENT_RANK() Percentage rank value RANK() Rank of current row within its partition, with gaps ROW_NUMBER() Number of current row within its partition >> MySQL :: MySQL 8.4 Reference Manual :: 14.20.1 Window Function Descriptions
MySQL :: MySQL 8.4 Reference Manual :: 14.20.1 Window Function Descriptions
14.20.1 Window Function Descriptions This section describes nonaggregate window functions that, for each row from a query, perform a calculation using rows related to that row. Most aggregate functions also can be used as window functions; see Section 14
dev.mysql.com
2. 윈도우 함수 사용 예제
-> 윈도우 함수는 항상 over () 와 함께 사용된다. [ over_clause 구문이라고 함.]
1) row_number
select row_number() over (order by ename) as "순번", ename, sal from emp;
2) RANK()
'IT 공부방 [기본지식 정리] > 데이터베이스 (DB)' 카테고리의 다른 글
107. 서브쿼리 (0) 2025.03.28 106. 프로시저 함수 (0) 2025.03.28 102. [MySQL] DML - 데이터 관리 언어 (0) 2025.03.26 110. [MySQL] 테이블 생성 타입표 (0) 2025.03.26 100.MySQL [8.0x] (0) 2025.03.26