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.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!