A newer version of this documentation is available.

View Latest
March 9, 2025
+ 12

Comparison functions determine the greatest or least value from a set of values.

GREATEST(expression1, expression2, ...)

Description

Largest non-NULL, non-MISSING value if the values are of the same type; otherwise NULL.

Example

Example 1. Find the largest value from a list of parameterss
Query
sql++
select GREATEST(30, 20, 26, 12) as biggest
Result
[
  {
    "biggest": 30
  }
]

LEAST(expression1, expression2, ...)

Description

Returns smallest non-NULL, non-MISSING value if the values are of the same type, otherwise returns NULL.

Example

Example 2. Find the largest value from a list of parameterss
Query
sql++
select LEAST(30, 20, 26, 12) as smallest
Result
[
  {
    "smallest": 12
  }
]