MySQL MIN() Function (original) (raw)

Last Updated : 28 Mar, 2026

The MySQL MIN() function is used to retrieve the smallest value from a specified column in a table. It helps quickly identify the minimum value without manually scanning all records.

**Syntax:

SELECT MIN(column_name) FROM table_name WHERE condition;

Working with the MySQL MIN() Function

The MIN() function is used to find the smallest value in a column, helping quickly analyze minimum data from a dataset. First, we will create a demo table on which the MIN() function will be applied:

Screenshot-2026-03-28-100102

sales Table

Example 1: Using the MIN() Function

This example shows how to retrieve the smallest value from a column using the MIN() function.

**Query:

SELECT MIN(product_id)
FROM sales;

**Output:

Screenshot-2026-03-28-100335

Example 2: Using MIN() with Conditions

This example demonstrates how to filter records using WHERE before finding the minimum value.

**Query:

SELECT MIN(amount) AS minimum_amount FROM sales WHERE amount > 150;

**Output:

Screenshot-2026-03-28-100451

Example 3: Using MIN() with GROUP BY

This example shows how to find the minimum value for each group using the GROUP BY clause.

**Query:

SELECT product_id, MIN(amount) AS minimum_amount FROM sales GROUP BY product_id;

**Output:

Screenshot-2026-03-28-100551