Other Functions and Features
These are miscellaneous functions and features that do not fall into any of the previous categories.
Least and Greatest
How do you get the smallest and largest values from a list?
IBM DB2
(CASE WHEN <arg1> < <arg2> THEN <arg1> ELSE <arg2> END) (CASE WHEN <arg1> > <arg2> THEN <arg1> ELSE <arg2> END)
If you have to worry about NULL values:
(CASE WHEN <arg2> IS NULL OR <arg1> < <arg2> THEN <arg1> ELSE <arg2> END) (CASE WHEN <arg2> IS NULL or <arg1> > <arg2> THEN <arg1> ELSE <arg2> END)
MySQL
LEAST(<arg1>, <arg2>) GREATEST(<arg1>, <arg2>)
For NULL values use a CASE statement.
Oracle
LEAST(<arg1>, <arg2>) GREATEST(<arg1>, <arg2>)
For NULL values use a CASE statement.
Postgres
LEAST(<arg1>, <arg2>) GREATEST(<arg1>, <arg2>)
SAS proc sql
(CASE WHEN <arg1...