max

Aggregate function that calculates the maximum across a group of values.

Example:

  1. SELECT max(salary) FROM employees;
  1. SELECT department, max(salary) FROM employees GROUP BY department;

If you need non-aggregate function to choose a maximum of two values, see greatest:

  1. SELECT greatest(a, b) FROM table;