Skip to content

Check whether two values are unequal or equal and obtain the maximum and minimum values from multiple columns

Use the IS DISTINCT FROM function to check whether two values are unequal. Use the IS NOT DISTINCT FROM function to check whether two values are equal. Use the greatest function to obtain the maximum value from multiple columns. Use the least function to obtain the minimum value from multiple columns.

SQL
* |
SELECT
  NULL IS DISTINCT
FROM  NULL,
  NULL IS NOT DISTINCT
FROM  NULL,
  greatest(1, 2, 3) as max,
  least(1, 2, 3) as min