Beginner

330. LEAST Function

Learn how to return the smallest value among multiple expressions.

📘 Lesson 330 of 728 ⏱ 9 min 🎯 Intermediate

The LEAST function compares multiple expressions and returns the smallest value, subject to database-specific NULL handling rules.

Row-level minimum comparisons are useful when analyzing prices, response times, scores, or multiple business metrics.

Find the lowest price offered across three sales channels.

SQL
SELECT
    ProductID,
    LEAST(OnlinePrice, StorePrice, PartnerPrice) AS LowestPrice
FROM ProductPrices;

LEAST can support pricing analysis, minimum-value checks, risk analysis, and row-level business comparisons.

  • LEAST compares multiple expressions.
  • It returns the smallest value.
  • It performs row-level comparisons.
  • NULL behavior varies by database.
  • It differs from the aggregate MIN function.
What does LEAST do?

LEAST returns the smallest value among the supplied expressions.

How is LEAST different from MIN?

LEAST compares values within an individual row, while MIN generally calculates the smallest value across multiple rows.

Have you finished this lesson?

Introduction to SQL – All Lessons