The GREATEST function returns the greatest element that is not NULL from a set of values.
It supports all PQL types (including table columns) as input. All arguments must be of the same data type. The data type of the result is the same as the data type of the input columns or values.
The GREATEST function requires at least two expressions.
For the STRING type, GREATEST only supports the ASCII range of characters, and not the full Unicode character set.
If all values are NULL, then GREATEST will also return NULL.
- In the argument list, you can mix columns with constants. This allows you to define a constant default value for the case.
- The GREATEST function might be a good alternative to CASE WHEN statements for its reduced syntax.
- The LEAST function is the reverse function of GREATEST.