How do I get the MIN() of two fields in Postgres?

LEAST(a, b):

The GREATEST and LEAST functions select the largest or smallest value from a 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 (see Section 10.5 for details). NULL values in the list are ignored. The result will be NULL only if all the expressions evaluate to NULL.

Note that GREATEST and LEAST are 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...


Here's the link to docs for the LEAST() function in PostgreSQL:

http://www.postgresql.org/docs/current/static/functions-conditional.html#AEN15582