# min

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: min
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/aggregate-functions/min
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/aggregate-functions/min.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/aggregate-functions/min.adoc
description: "`min()` is a function that returns the minimum value from a set of records."
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/aggregate-functions/min.md -->

`min()` is a function that returns the minimum value from a set of records.

## [](#syntax)Syntax

The syntax for this function is:

```sql
MIN(column_name)
```

This function’s output data type will always be the same as the input one, however it returns `NULL` if there are no records or input consists of `NULL` values and it also returns `NaN` if the input contains a `NaN`.

## [](#examples)Examples

The following examples use a movies table that stores movie details, such as movie’s title, category, and IMDb rating.

```sql
CREATE TABLE movies (
    movieid int,
    moviename text,
    moviecategory text,
    imdbrating real
);
INSERT INTO movies (movieid, moviename, moviecategory, imdbrating)
VALUES
(8557411, 'The Shawshank Redemption', 'Drama', 9.4),
(8557421, 'Life Is Beautiful', 'Romance', 8.4),
(8557451, 'The Godfather', 'Crime', 9.3),
(8557311, 'Prisoners', 'Thriller', 8.5),
(8557321, 'Inception', 'Science Fiction', 9),
(8557351, 'The Dark Knight', 'Action', 9.2),
(8557221, 'Coco', 'Drama', 8.2),
(8557251, 'The Sixth Sense', 'Horror', 8.1),
(8557231, 'Kill Bill: Vol. 1', 'Action', 8.1),
(8557281, 'The Notebook', 'Romance', 7.8),
(8557291, 'Forrest Gump', 'Drama', 8);
```

```sql
SELECT * FROM movies;
```

The query returns:

```sql
+---------+--------------------------+-----------------+-------------+
| movieid | moviename                | moviecategory   | imdbrating  |
+---------+--------------------------+-----------------+-------------+
| 8557411 | The Shawshank Redemption | Drama           | 9.4         |
| 8557421 | Life Is Beautiful        | Romance         | 8.4         |
| 8557451 | The Godfather            | Crime           | 9.3         |
| 8557311 | Prisoners                | Thriller        | 8.5         |
| 8557321 | Inception                | Science Fiction | 9           |
| 8557351 | The Dark Knight          | Action          | 9.2         |
| 8557221 | Coco                     | Drama           | 8.2         |
| 8557251 | The Sixth Sense          | Horror          | 8.1         |
| 8557231 | Kill Bill: Vol. 1        | Action          | 8.1         |
| 8557281 | The Notebook             | Romance         | 7.8         |
| 8557291 | Forrest Gump             | Drama           | 8           |
+---------+--------------------------+-----------------+-------------+
```

### [](#min-with-a-single-expression)`min()` with a single expression

For example, you might want to know what is the lowest rating of all stored movies:

```sql
SELECT MIN(imdbRating) AS "Lowest Rating"
FROM movies;
```

```sql
+----------------+
| Lowest Rating  |
+----------------+
| 7.8            |
+----------------+
```

### [](#min-with-group-by-clause)`min()` with `GROUP BY` clause

This example uses a `GROUP BY` clause to group the movie categories, then uses the `min()` function to get the lowest rating in each movie category and arrange the results in ascending order.

```sql
SELECT
  movieCategory AS "Movie Category",
  MIN(imdbRating) AS "Lowest Rating"
FROM movies
GROUP BY movieCategory
ORDER BY MIN(imdbRating) ASC;
```

The query returns:

```sql
 Movie Category  | Lowest Rating
-----------------+---------------
 Romance         |           7.8
 Drama           |             8
 Horror          |           8.1
 Action          |           8.1
 Thriller        |           8.5
 Science Fiction |             9
 Crime           |           9.3
(7 rows)
```