Returns the minimum value within the requested window.

For more information on usage, please refer to Window Functions.

Syntax

MIN( <expression> ) OVER ( [ PARTITION BY <partition_by> ] )

Parameters

ParameterDescriptionSupported input types
<expression>A value used for the MIN functionAny
<partition_by>An expression used for the PARTITION BY clause.Any

Example

The example below queries test scores for players in various grade levels. Unlike a regular MIN() aggregation, the window function highlights how each player individually compares to the lowest game score for their level.

SELECT
	nickname,
	level,
	current_score,
	MIN(current_score) OVER (PARTITION BY level) AS lowest_score
FROM
	players;

Returns:

nicknamelevelcurrent_scorelowest_score
kennethpark9762
sabrina2179015
burchdenise5794
ymatthews6859
rileyjon88020