A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/postgresql/postgresql-min-function/ below:

PostgreSQL MIN() Function - GeeksforGeeks

PostgreSQL MIN() Function

Last Updated : 15 Jul, 2025

The MIN() function in PostgreSQL is an essential aggregate function that returns the minimum value in a set of values. This function is highly useful in various data analysis and reporting tasks, allowing you to quickly identify the smallest values in your datasets.

Let us better understand the MIN() Function in PostgreSQL to better understand the concept.

Syntax
MIN(expression)

Where 'expression' represents the column or expression from which you want to find the minimum value.

PostgreSQL MIN() Function Examples

Let us take a look at some of the examples of the MIN() Function in PostgreSQL to better understand the concept. For example, we will be using the sample database (ie, dvdrental).

Example 1: Finding the Minimum Payment Amount

The following query retrieves the smallest payment amount recorded in the 'payment' table.

Query:

SELECT MIN(amount)
FROM payment;

Output:

Explanation: This query scans the 'amount' column in the 'payment' table and returns the minimum value, which represents the lowest payment made by any customer.

Example 2: Minimum Payment Per Customer

The next example shows how to find the smallest payment made by each customer. This involves grouping the results by 'customer_id'.

Query:

SELECT
customer_id,
MIN(amount)
FROM
payment
GROUP BY
customer_id;

Output:

Explanation: In this query, 'customer_id' is used to group the payments. The MIN(amount) function finds the smallest payment for each customer within these groups.

Important Points About PostgreSQL MIN() Function


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4