If you haven’t already heard, SQL 2022 has introduced a new built-in system function called GREATEST. Simply put, it is to a set of columns, variables, expressions etc. what the
MAXfunction is to a set of values (i.e., rows) of a single column or expression. The opposite of
LEASTfunction which returns the smallest value from the supplied list of columns, variables, constants etc.
LEASTcan be considered a pair, just as
In other situations,
LEAST() are known as
Drupal shows us two alternatives to the built-in function and includes a performance comparison.