Reputation: 2498
I need to get maximum value of certain number of columns (for each row). Is this possible to do in MySQL?
For example:SELECT MAX(column1, column2, column3)
.
I'm not looking for MAX function that aggregates values of a given column. I need to aggregate values of different columns for each row.
Upvotes: 4
Views: 161
Reputation: 453648
You need the GREATEST
function
SELECT GREATEST(column1, column2, column3) AS X
Upvotes: 9