select name, case when case when x > y then x else y end < z then z else case when x < y then y else x end end as greasterfrom greatests