MIN and MAX
When working with data, it is often useful to have a general sense of the spread and distribution of your data.
Simple functions like
MAX()
The MAX() function returns the maximum value, typically numeric or date from a specific column in a query. For
example, we can return the maximum price from the
SELECT
MAX(price) AS maximum_price
FROM product
maximum_price --------------- 3899.99 (1 row)
MIN()
Conceptually similar to the MAX() function, the MIN() function returns the minimum value of the column specified in the query. Let's see the exact opposite of the query we have above.
SELECT
MIN(price) AS minimum_price,
MAX(price) AS maximum_price
FROM product
minimum_price | maximum_price ---------------+--------------- 24.99 | 3899.99 (1 row)