MIN Function - (MariaDB Aggregate Functions)
The MIN function is a built-in MariaDB Aggregate Function that is used to find the minimum value in a set of values. It can be used in SELECT statements to return the minimum value of a selected column.
Syntax
SELECT MIN(column_name) FROM table_name;
Here, column_name
is the name of the column that we want to find the minimum value for, and table_name
is the name of the table in which the column is stored.
Example
Consider the following sample table named employees
:
id | first_name | last_name | age |
---|---|---|---|
1 | John | Smith | 30 |
2 | Jane | Doe | 25 |
3 | Bob | Johnson | 40 |
We can find the minimum age of the employees using the following SQL query:
SELECT MIN(age) FROM employees;
Output
The above SQL query will return the following output:
MIN(age) |
---|
25 |
Explanation
In the above query, we are selecting the minimum value of the age
column from the employees
table using the MIN function.
Use
The MIN function can be used in a variety of situations to find the minimum value of a set of data. For example, it can be used to find the minimum price of a product, the minimum time taken to complete a task, or the minimum score in a game.
Important Points
- The MIN function is a built-in MariaDB Aggregate Function that is used to find the minimum value in a set of values.
- It can be used in SELECT statements to return the minimum value of a selected column.
- The MIN function can be used to find the minimum value in a variety of situations.
Summary
In summary, the MIN function is a built-in MariaDB Aggregate Function that is used to find the minimum value in a set of values. It can be used in SELECT statements to return the minimum value of a selected column. The MIN function can be used to find the minimum value in a variety of situations, including finding the minimum price of a product, the minimum time taken to complete a task, or the minimum score in a game.