- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
A window function applies an aggregation to some subset of the rows selected by a query. The selected rows are preserved in the query output, rather than being grouped into a single output row as they would be in a non-window aggregation.
For details on how window functions work, see the Postgres documentation for Window Function.
function_name ([expression [, expression ...]]) OVER (
[ PARTITION BY expression [, ...] ]
[ ORDER BY expression [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ]
[ frame_clause ]
)
The optional frame_clause
has the following syntax:
{ RANGE | ROWS } frame_start
| { RANGE | ROWS } BETWEEN frame_start AND frame_end
The frame_start
and frame_end
expressions can be one of the following:
UNBOUNDED PRECEDING
offset PRECEDING
CURRENT ROW
offset FOLLOWING
UNBOUNDED FOLLOWING
The functions below can be used in windows, along with the aggregation functions.
Name | Return type | Description |
---|---|---|
row_number() | integer | Returns the number of the current row within its partition, counting from 1. |
Name | Return type | Description |
---|---|---|
rank() | integer | Returns the rank of the current row, with gaps (the row_number of the first row in its peer group). |
Name | Return type | Description |
---|---|---|
dense_rank() | integer | Returns the rank of the current row, without gaps. This function effectively counts peer groups. |
Name | Return type | Description |
---|---|---|
first_value(value T) | T | Returns the value evaluated at the row that is the first row of the window frame. |
Name | Return type | Description |
---|---|---|
last_value(value T) | T | Returns the value evaluated at the row that is the last row of the window frame. |