My first attempt was:
SELECT id, MAX(column1, column2) FROM table1;which of course didn't work because MAX() is an aggregate function which only takes a single parameter.
What I was looking for instead, is something that was introduced in 8.1:
SELECT id, GREATEST(column1, column2) FROM table1;where GREATEST() (and its opposite: LEAST()) is a conditional expression.



1 comments:
shouldn't that be Greatest+Smallest or Most+Least?
Post a Comment