The Wayback Machine - https://web.archive.org/web/20220619232556/https://www.geeksforgeeks.org/postgresql-min-function/
Skip to content
Related Articles

Related Articles

PostgreSQL – MIN() Function

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 01 Jun, 2020

PostgreSQL MIN() function is an aggregate function that returns the minimum value in a set of values.

Syntax: MIN(expression);

The MIN() function can be used with SELECT, WHERE and HAVING clause.

Now let’s look into some examples.For examples we will be using the sample database (ie, dvdrental).
Example 1:
The below query gets us the minimum amount paid by customers in the payment table:

SELECT MIN(amount)
FROM payment;

Output:

Example 2:
The following query gets the smallest payment paid by each customer:

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

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!