select
case greatest(col1,col2,col3,col4)
when col1 then 'col1:' || col1
when col2 then 'col2:' || col2
when col3 then 'col3:' || col3
when col4 then 'col4:' || col4
else null
end as greatestcolumnname
from mytable;
select
case greatest(col1,col2,col3,col4)
when col1 then 'col1:' || col1
when col2 then 'col2:' || col2
when col3 then 'col3:' || col3
when col4 then 'col4:' || col4
else null
end as greatestcolumnname
from mytable;