How to find largest, highest OR maximum value among columns of a row

There are certain scenarios when we need to fetch largest, maximum or highest value among multiple columns of a filtered row. In such case below function is useful.

GREATEST(value [, ...])
  • The¬†GREATESTfunction selects the largest / maximum / highest value from a list of columns/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.
  • NULL values in the list are ignored. The result will be NULL only if all the expressions evaluate to NULL.
  • Note that,GREATEST not in the SQL standard, but are a common extension. Some other databases make them return NULL if any argument is NULL, rather than only when all are NULL.

Leave a Reply