After too many hours I can't find the answer to this.
First my table
id | one | two | three | four | five | galname
-------------------------------------------------
1 | 2 | 5 | 23 | 4 | 5 | Bob
How do I find the highest value in the row and show colomun name.
three - 23
select id, GREATEST(one, two, three, four, five) value,
case GREATEST(one, two, three, four, five)
when one then 'one'
when two then 'two'
when three then 'three'
when four then 'four'
when five then 'five' end column_name
from your_table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With