Least Function In Sql in SQL
LEAST Function in SQL
The LEAST function returns the smallest (minimum) value from a list of expressions.
Syntax:
LEAST(value1, value2, value3, ...)Compares the values and returns the smallest one.
Example:
SELECT LEAST(10, 25, 5, 30) AS smallest_value;Result:
| smallest_value |
|---|
| 5 |
Notes:
Works with numbers, strings (alphabetical order), and dates.
If any value is
NULL, result isNULL(in most databases).Supported in MySQL, Oracle, PostgreSQL. Not supported directly in SQL Server (you can use
CASEor other methods instead).
If you want examples in a specific database or more use cases, let me know!