Skip to main content

Overview

The MIN() window function is used to compute the minimum value of an expression across a set of rows defined by a window specification.

Syntax

The syntax for this function is as follows:

Parameters

  • ALL: retains all duplicate values from the expression

Example

For the needs of this section we will use a simplified version of the film table from the Pagila database, containing only the title, length and rating columns. The complete schema for the film table can be found on the Pagila database website.
The query below uses the MIN() to find the minimum length of films for each rating category and also calculates a running minimum length of films ordered by their length.
By running the above code, we will get the following output: