postgresql_16:3.6.18.4 GREATEST and LEAST
PostgreSQL 16 > The SQL Language > Functions and Operators > Conditional Expressions > GREATEST and LEAST
GREATEST(value , ...)
LEAST(value , ...)
The GREATEST and LEAST functions select the largest or smallest value from a list of any number of expressions. The expressions must all be convertible to a common data type, which will be the type of the result (see (see postgresql_16:3.7.5) for details).
NULL values in the argument list are ignored. The result will be NULL only if all the expressions evaluate to NULL. (This is a deviation from the SQL standard. According to the standard, the return value is NULL if any argument is NULL. Some other databases behave this way.)