The SQLite MIN
function calculates and returns the minimum value of all values in a set.
Syntax
Here is the syntax of SQLite MIN function:
SELECT MIN(column_name) FROM table_name;
The type of column_name must be NUMERIC
or INTEGER
.
Example
Table of books
ID | NAME | PRICE |
---|---|---|
1 | SQLite | 10 |
2 | SQL | 20 |
3 | PL/SQL | 30 |
4 | PHP | NULL |
5 | Python | 20 |
6 | HTML | 40 |
MIN function example
SELECT MIN(PRICE) FROM books; MIN result: 10
The example above shows how to get the minimum price of a book. For this, the SELECT statement uses the PRICE column inside the brackets of the MIN function.