SQLite 3 reference · Aggregate Functions

SQLite MIN() Function

With one argument, return the smallest value in a group. With two or more, return the smallest of the arguments.

SQLite 3

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

min(X)  |  min(X, Y, ...)

Parameters

ParameterDescription
X A column or expression.

Return value

The smallest value, or NULL.

Examples

As an aggregateTry it yourself
SELECT min(price) AS cheapest, min(stock) AS lowest_stock
FROM products;

Output

cheapest | lowest_stock
5.5 | 0
As a scalar functionTry it yourself
SELECT name, stock, min(stock, 20) AS capped_at_20
FROM products
WHERE product_id IN (1, 4, 9);

Output

name | stock | capped_at_20
SQL for Beginners | 40 | 20
Mechanical Keyboard | 25 | 20
Desk Lamp | 12 | 12

In other languages

Was this page helpful?