~0>>1
会给你mysql中最大的BigInt值(应该够用了)
coalesce(
nullif(
least(coalesce(value1, ~0>>1), coalesce(value2, ~0>>1),
coalesce(value3, ~0>>1), coalesce(value4, ~0>>1)),
~0>>1),
0)
或者你必须做组合(我把它们都放了,不确定是否有必要)
coalesce
(least(
coalesce(value1, value2, value3, value4),
coalesce(value1, value2, value4, value3),
coalesce(value1, value3, value2, value4),
coalesce(value1, value3, value4, value2),
coalesce(value1, value4, value2, value3),
coalesce(value1, value4, value3, value2),
coalesce(value2, value1, value3, value4),
coalesce(value2, value1, value4, value3),
coalesce(value2, value3, value1, value4),
coalesce(value2, value3, value4, value1),
coalesce(value2, value4, value1, value3),
coalesce(value2, value4, value3, value1),
coalesce(value3, value1, value2, value4),
coalesce(value3, value1, value4, value2),
coalesce(value3, value2, value1, value4),
coalesce(value3, value2, value4, value1),
coalesce(value3, value4, value1, value2),
coalesce(value3, value4, value2, value1),
coalesce(value4, value1, value2, value3),
coalesce(value4, value1, value3, value2),
coalesce(value4, value2, value1, value3),
coalesce(value4, value2, value3, value1),
coalesce(value4, value3, value1, value2),
coalesce(value4, value3, value2, value1)
)
, 0)