Skip to content

GREATEST

  • value1: This is the first value of the comparison in the `GREATEST` function. It can be any valid SQL literal or column value.
  • value2: This is the second comparative value in the `GREATEST` function. Like `value1`, it can also be any valid SQL literal, or column value.
  • …, valuen: This denotes that the GREATEST function can take any number of arguments. Each of these values (`value3`, `value4`, `valueN`, etc.) are additional comparative values, and can also be any valid SQL literal, or column value.
SELECT GREATEST(3, 27, 14, 9, 5);
27

The GREATEST function in MySQL returns the greatest value from the list of parameters. The above example compares five numbers: 3, 27, 14, 9, and 5. The largest of these numbers is 27, and therefore it’s the returned output.