MySQL MIN Aggregate Function is to find the minimum value of total rows (or records) selected by the SELECT Statement. For example, If you want to find the least performing product in your Store, then you can simply use this Minimum function.
The basic syntax of the MySQL MIN function is
SELECT MIN([Column_Name]) FROM [Source]
It ignores the NULL values while finding the Minimum value. How to find Minimum in MySQL with an example using the below shown data.
MySQL MIN Function Example
The MySQL Min function returns the minimum value present in the specified column. For example, the following query returns the Minimum or Lowest value present in the Sales column from the customer details table.
SELECT MIN(Sales) AS `Minimum Sales` FROM customerdetails;
MIN Group By Example
In general, we use this to check for the least performing products belonging to a particular color or category, etc. In this situation, we can use Group By Clause to group the products by color or category. Next, we use the MySQL MIN or Minimum Function to find the lowest value in each group by. Let us see the Example.
USE company; SELECT Profession, MIN(Sales) FROM customerdetails GROUP BY Profession;
The above Aggregate query group the Customers by their profession and finds the least sales in each group
You can use DISTINCT Keyword along with the MIN function to remove the Duplicates from the specified column Name. But, it gives the same result as the above SELECT Statement (without using the MySQL DISTINCT keyword).