用多了 max() 、min() 今天刚好遇到了需要取连续6年中营收最大的逻辑(6列)
greatest函数
取多列最大值
select greatest(-99, 0, 73) --73
存在...2020,
if(income_2021 is null,-9999999,income_2021) income_2021
from table
) a;
least函数...取多列最小值
select least(-99, 0, 73) -- -99
存在 null 或者字符串
select least(-99, 0, 73, null) --null
select least