We have 2 columns in a table and want to SELECT the lesser most of the two (unless it is equal to 0, then we want the nonzero column).
Is there a way to do this while keeping it a simple SELECT statement?
What we want is this:
SELECT LEAST(col1, col2) FROM myTable
Unless col2 is 0, in which case we want col1.
1 Answer