The LEAST function compares multiple expressions and returns the smallest value according to the database system's comparison rules.
Finding the lowest value across multiple columns is useful when comparing prices, performance values, scores, or business measurements.
Find the lowest price offered by three suppliers.
SELECT
ProductID,
LEAST(SupplierPrice1, SupplierPrice2, SupplierPrice3) AS LowestPrice
FROM ProductPrices;
LEAST can be used in procurement analysis, pricing comparisons, risk analysis, and performance monitoring.
- LEAST returns the smallest value.
- It compares multiple expressions.
- It is useful for row-level comparisons.
- NULL handling can vary by database.
- Database support should be checked.
What does LEAST do?
LEAST returns the smallest value among the supplied expressions.
How is LEAST different from MIN?
LEAST usually compares values across columns or expressions within a row, while MIN commonly returns the smallest value across multiple rows.