Small. Fast. Reliable.
Choose any three.
Window Functions
Table Of Contents

1. Introduction to Window Functions

A window function is an SQL function where the input values are taken from a "window" of one or more rows in the results set of a SELECT statement.

Window functions are distinguished from scalar functions and aggregate functions by the presence of an OVER clause. If a function has an OVER clause, then it is a window function. If it lacks an OVER clause, then it is an ordinary aggregate or scalar function. Window functions might also have a FILTER clause in between the function and the OVER clause.

The syntax for a window function is like this:

window-function-invocation:

window-func ( expr ) filter-clause OVER window-name window-defn , *

expr: