<p>Let's say I have a table like this:</p>

<pre><code>name | score_a | score_b
-----+---------+--------
 Joe |   100   |   24
 Sam |    96   |  438
 Bob |    76   |  101
 ... |   ...   |  ...
</code></pre>

<p>I'd like to select the minimum of score_a and score_b. In other words, something like:</p>

<pre><code>SELECT name, MIN(score_a, score_b)
FROM table
</code></pre>

<p>The results, of course, would be:</p>

<pre><code>name | min
-----+-----
 Joe |  24
 Sam |  96
 Bob |  76
 ... | ...
</code></pre>

<p>However, when I try this in Postgres, I get, "No function matches the given name and argument types. You may need to add explicit type casts." MAX() and MIN() appear to work across <em>rows</em> rather than <em>columns.</em></p>

<p>Is it possible to do what I'm attempting?</p>

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...