## How to Use the MySQL MIN() Function

In this tutorial, you'll learn how to use the **MySQL MIN**() function. **MIN**() is a function to return the minimum value in a group of values.

For example, let's say you have a list of items that you're selling, and you want to know which item has the lowest sales price. In this case, you can use the **MIN**() function.

### MySQL MIN() Syntax

The syntax of the **MIN**() function is as follows:

MIN(expression)

### Examples

The following is the demo ** orders** table we're going to use in the examples:

order_number | order_date | customer | amount |
---|---|---|---|

#ORD_00001 | 2019-11-12 | Gloria Harvey | 2450.50 |

#ORD_00002 | 2019-10-03 | Annie Mitchell | 2000.00 |

#ORD_00003 | 2019-10-03 | Grant Daniels | 1890.40 |

#ORD_00004 | 2019-11-10 | Thomas Pratt | 1370.50 |

#ORD_00005 | 2019-11-12 | Ronald Houston | 2780.50 |

#ORD_00006 | 2019-11-12 | Vera Bell | 1290.00 |

#ORD_00007 | 2019-10-04 | Lindsay Leonard | 1768.00 |

#ORD_00008 | 2019-10-04 | Mario Simmons | 2340.50 |

#### Example 1: MIN() without WHERE Clause

Let's say you want to get the smallest amount in the **"amount"** column. You can write the statement as follows:

SELECTMIN(orders.amount)ASSmallestAmountFROMorders;

**Result**:

This statement returns 1290.00, which is the smallest value.

#### Example 2: MIN() and WHERE Clause

The following SQL statement returns the smallest amount, where **order_date** is 2019-11-12:

SELECTMIN(orders.amount)ASSmallestAmountFROMordersWHEREorder_date = '2019-11-12';

**Result**:

The above statement returns 1290.00.

#### Example 3: MIN() and AND Operator

In this example, I show you how to use the **MIN() function** and **AND operator** in the **WHERE clause**.

The following SQL statement returns the minimum value between two dates:

SELECTMIN(o.amount)ASSmallestAmountFROMorders oWHEREo.order_date >= '2019-10-01'ANDo.order_date <= '2019-10-05';

**Result**:

MySQL searches for the smallest amount between 2019-10-01 and 2019-10-05 and returns 1768.00.

In this tutorial, you've learned how to use the **MySQL MIN**() function. **MIN**() is an aggregate function to get the minimum value in a group. If you want to find the maximum value in a group of values, then you can use the **MAX**() function.