Skip to content
SQLSimplified
numeric

LEAST()

Returns the smallest value from a list of expressions.

Description

LEAST returns the lowest value among its arguments — a row-level "min across columns" (unlike the MIN aggregate, which is across rows). LEAST(3, 7, 5) is 3. Use it to cap a value or pick the earlier of two dates.

Syntax

LEAST(expr1, expr2, ...)

Parameters

NameDescriptionOptional
expr1, expr2, ...Two or more expressions of compatible types.No

Return Type

Returns the same type as the inputs.

Examples

Employees & Departments

Loading database engine...

Employees & Departments

Loading database engine...

LEAST vs MIN

LEAST compares values within a single row (across columns); MIN is an aggregate that compares rows within a group.

Common Mistakes

  • NULL handling. A single NULL argument can make the result NULL; wrap inputs in COALESCE if you want to ignore NULLs.
  • Mixing types. Arguments should be compatible types.
  • Confusing with MIN. LEAST is per-row, not per-group.

See also: GREATEST, MIN.

Search

Search lessons, functions, examples, and practice problems