I have a MySQL query that uses the GREATEST()
function, and I want to rewrite it in standard ANSI SQL to work in other databases. I know that GREATEST is supported by most SQL databases, but I will probably run the query in Hive, which supports things like CASE but not GREATEST.
Can anyone think of an elegant way to rewrite this query without using GREATEST()
?
Thanks!
select greatest(play,play_25,play_50,play_75,play_100) as play, greatest(play_25,play_50,play_75,play_100) as play_25, greatest(play_50,play_75,play_100) as play_50, greatest(play_75,play_100) as play_75, play_100 as play_100 from video_buckets
source share