LEAST
conditional or n-ary selection
What changes
- Input
- a condition or index and value list
- Output or change
- one of the inputs
- Return type
- Returns the data type with the highest precedence from the set of types passed to the function. For more information, see Data Type Precedence (Transact-SQL). If all arguments have the same data type
Syntax at a glance
LEAST ( expression1 [ , ...expressionN ] )
Work example
Choose the smallest nonnull value from several expressions in one row.
Cast mixed inputs deliberately and check whether null means unknown or should be ignored.
Check your work LEAST follows type precedence and returns null when every argument is null.
Open Microsoft Learn for full syntax, permissions, and details for your version.