Drupal Grupal gives us alternatives:
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
MAX
function is to a set of values (i.e., rows) of a single column or expression. The opposite ofGREATEST
function isLEAST
function which returns the smallest value from the supplied list of columns, variables, constants etc.GREATEST
&LEAST
can be considered a pair, just asMIN
/MAX
functions are.
In other situations, GREATEST()
and LEAST()
are known as ARGMAX()
and ARGMIN()
, respectively.
Drupal shows us two alternatives to the built-in function and includes a performance comparison.