select LEAST(a, b, c, d), cyrq = GREATEST(a, b, c, d) from table