MIN function [Aggregate]

Returns the minimum expression value found in each group of rows.

Syntax 1
MIN( expression | DISTINCT expression )
Syntax 2
MIN( expression ) OVER ( window-spec )
window-spec : see Syntax 2 instructions in the Remarks section below
Parameters
  • expression   The expression for which the minimum value is to be calculated. This is commonly a column name.

  • DISTINCT expression   Returns the same as MIN( expression ), and is included for completeness.

Returns

The same data type as the argument.

Remarks

Rows where expression is NULL are ignored. Returns NULL for a group containing no rows.

Syntax 2 represents usage as a window function in a SELECT statement. As such, elements of window-spec can be specified either in the function syntax (inline), or in conjunction with a WINDOW clause in the SELECT statement. See the window-spec definition provided in WINDOW clause.

For more information about using window functions in SELECT statements, including working examples, see Window functions.

This function supports NCHAR inputs and/or outputs.

See also
Standards and compatibility
  • SQL/2003   Core feature. Syntax 2 is feature T611.

Example

The following statement returns the value 24903.000, representing the minimum salary in the Employees table.

SELECT MIN( Salary )
FROM Employees;