Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions documentation/query/functions/window-functions/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Window Functions Overview
sidebar_label: Overview
description: Introduction to window functions in QuestDB - perform calculations across related rows without collapsing results.
keywords: [window functions, over, partition by, moving average, running total, rank, dense_rank, percent_rank, row_number, lag, lead, analytics, ema, vwema, ksum, exponential moving average, stddev, variance, covariance, correlation]
keywords: [window functions, over, partition by, moving average, running total, rank, dense_rank, percent_rank, ntile, cume_dist, row_number, lag, lead, nth_value, analytics, ema, vwema, ksum, exponential moving average, stddev, variance, covariance, correlation]
---

Window functions perform calculations across sets of table rows related to the current row. Unlike aggregate functions that return a single result for a group of rows, window functions return a value for **every row** while considering a "window" of related rows defined by the `OVER` clause.
Expand Down Expand Up @@ -44,23 +44,26 @@ Arithmetic operations on window functions (e.g., `sum(...) OVER (...) / sum(...)
| Function | Description | Respects Frame |
|----------|-------------|----------------|
| [`avg()`](reference.md#avg) | Average value in window (also supports EMA and VWEMA) | Yes (standard) / No (EMA/VWEMA) |
| [`corr()`](reference.md#corr) | Pearson correlation coefficient | Yes |
| [`count()`](reference.md#count) | Count rows or non-null values | Yes |
| [`sum()`](reference.md#sum) | Sum of values in window | Yes |
| [`ksum()`](reference.md#ksum) | Sum with Kahan precision | Yes |
| [`min()`](reference.md#min) | Minimum value in window | Yes |
| [`max()`](reference.md#max) | Maximum value in window | Yes |
| [`stddev_pop()` / `stddev_samp()` / `stddev()`](reference.md#stddev) | Standard deviation (population or sample) | Yes |
| [`var_pop()` / `var_samp()` / `variance()`](reference.md#variance) | Variance (population or sample) | Yes |
| [`covar_pop()` / `covar_samp()`](reference.md#covariance) | Covariance between two columns | Yes |
| [`corr()`](reference.md#corr) | Pearson correlation coefficient | Yes |
| [`first_value()`](reference.md#first_value) | First value in window | Yes |
| [`last_value()`](reference.md#last_value) | Last value in window | Yes |
| [`row_number()`](reference.md#row_number) | Sequential row number | No |
| [`rank()`](reference.md#rank) | Rank with gaps for ties | No |
| [`cume_dist()`](reference.md#cume_dist) | Cumulative distribution (0 to 1] | No |
| [`dense_rank()`](reference.md#dense_rank) | Rank without gaps | No |
| [`percent_rank()`](reference.md#percent_rank) | Relative rank (0 to 1) | No |
| [`first_value()`](reference.md#first_value) | First value in window | Yes |
| [`ksum()`](reference.md#ksum) | Sum with Kahan precision | Yes |
| [`lag()`](reference.md#lag) | Value from previous row | No |
| [`last_value()`](reference.md#last_value) | Last value in window | Yes |
| [`lead()`](reference.md#lead) | Value from following row | No |
| [`max()`](reference.md#max) | Maximum value in window | Yes |
| [`min()`](reference.md#min) | Minimum value in window | Yes |
| [`nth_value()`](reference.md#nth_value) | N-th value in window (`double` only) | Yes |
| [`ntile()`](reference.md#ntile) | Bucket number from 1 to N | No |
| [`percent_rank()`](reference.md#percent_rank) | Relative rank (0 to 1) | No |
| [`rank()`](reference.md#rank) | Rank with gaps for ties | No |
| [`row_number()`](reference.md#row_number) | Sequential row number | No |
| [`stddev_pop()` / `stddev_samp()` / `stddev()`](reference.md#stddev) | Standard deviation (population or sample) | Yes |
| [`sum()`](reference.md#sum) | Sum of values in window | Yes |
| [`var_pop()` / `var_samp()` / `variance()`](reference.md#variance) | Variance (population or sample) | Yes |

**Respects Frame**: Functions marked "Yes" use the frame clause (`ROWS`/`RANGE BETWEEN`). Functions marked "No" operate on the entire partition regardless of frame specification.

Expand Down
Loading
Loading