In PostgreSQL, the MAX function is used to return the maximum value within a specified column. It can be applied to columns of various data types such as numeric, date, and string.

Syntax:

SELECT MAX(column_name)
FROM table_name;

Example:

Imagine you have a table named 'students' with the following columns: id, name, and score.

| id | name | score | |----|--------|-------| | 1 | 'Alice' | 85 | | 2 | 'Bob' | 92 | | 3 | 'Charlie'| 88 |

To find the maximum value in the 'score' column, you can use the following query:

SELECT MAX(score)
FROM students;

The result will be 92, as 92 is the highest value in the 'score' column.

PostgreSQL MAX Function: Find the Maximum Value in a Column

原文地址: https://www.cveoy.top/t/topic/mcrr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录