SQLite MIN Function

SQLite MIN function is used to fetch the minimum value of an expression.

Syntax:

snippet
SELECT MIN(aggregate_expression)
FROM tables
[WHERE conditions];

Syntax when you use Min function with GROUP BY clause:

snippet
SELECT expression1, expression2, ... expression_n
MIN(aggregate_expression)
FROM tables
[WHERE conditions]
GROUP BY expression1, expression2, ... expression_n;

Example1:

We have a table named "STUDENT", having the following data:

Sqlite Min function 1

Retrieve the lowest fees of the student from the "STUDENT" table:

snippet
SELECT MIN(FEES) AS "Lowest Fees"
FROM STUDENT;

Output:

Sqlite Min function 2

Example2:

Using GROUP BY clause with MIN function:

Retrieve NAME and MIN FEES from the table "STUDENT" and ORDER BY the data by NAME:

snippet
SELECT NAME, MIN(FEES) AS "Lowest Fees"
FROM STUDENT
WHERE ID <= 5
GROUP BY NAME;

Output:

Sqlite Min function 3
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents