select kk from (select max(k1) as kk from table
union all
select max(k2) as kk from table
union all
select max(k3) as kk from table
union all
select max(k4) as kk from table
union all
select max(k5) as kk from table) newtable order by kk desc
case when k1>=k2 and k1>=k3 and k1>=k4 and k1>=k5 then k1
when k2>=k3 and k2>=k4 and k2>=k5 then k2
when k3>=k4 and k3>=k5 then k3
when k4>=k5 then k4
else k5
end
好像没有这样的函数,可以这样
select max(aa.kk) 最大值
from (select k1 as kk from 表 where 条件 union all
select k2 as kk from 表 where 条件 union all
select k3 as kk from 表 where 条件 union all
select k4 as kk from 表 where 条件 union all
select k5 as kk from 表 where 条件 ) aa