The SQL MIN function is used to retrieve the smallest value from a column in a database table. It is a built-in function in Structured Query Language (SQL) that can be used in SELECT statements to return the minimum value of a specified column.
The syntax of the MIN function is as follows:
SELECT MIN(column_name) FROM table_name;
In this syntax, column_name refers to the name of the column from which the minimum value needs to be retrieved, and table_name refers to the name of the table that contains the column.
For example, consider a table named Training_Course with columns id, name, duration, and price.
To retrieve the minimum price of all courses in the table, the following SQL query can be used:
select MIN(PRICE) from Training_Course;
It is also possible to use the MIN function with the GROUP BY clause to retrieve the minimum value of a column for each group of data in the table. For example, consider the following SQL query:
SELECT department, MIN(salary) FROM employees GROUP BY department;
This query will return the minimum salary value for each department in the employees table.
In summary, the SQL MIN function is a useful tool for retrieving the minimum value of a column in a database table. It can be used in conjunction with other SQL functions and clauses to perform more complex queries and retrieve specific data from a database.