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
Syntax
min(X) | min(X, Y, ...)
Parameters
| Parameter | Description |
|---|---|
X |
A column or expression. |
Return value
The smallest value, or NULL.
Examples
SELECT min(price) AS cheapest, min(stock) AS lowest_stock
FROM products;
Output
cheapest | lowest_stock 5.5 | 0
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
GREATEST()· PostgreSQLMIN()· PostgreSQL
Related
MAX()· With one argument, return the largest value in a group. With two or more, return the largest of the arguments.AVG()· Return the average of the non-NULL values in a group, always as a real number. NULLs are ignored, not counted as 0.- SQL Aggregate Functions · tutorial
- SQL GROUP BY · tutorial