1、GREATEST(n1,n2,n3,..........) 获取最大值
testdb=#SELECT GREATEST(3,5,1,8,33,99,34,55,67,43); +---------------------------------------------------------+ | GREATEST(3,5,1,8,33,99,34,55,67,43) | +---------------------------------------------------------+ | 99 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
2、LEAST(N1,N2,N3,N4,......) 获取最小值
testdb=#SELECT LEAST(3,5,1,8,33,99,34,55,67,43); +---------------------------------------------------------+ | LEAST(3,5,1,8,33,99,34,55,67,43) | +---------------------------------------------------------+ | 1 | +---------------------------------------------------------+ 1 row in set (0.00 sec)
其他更多函数参考:http://developer.51cto.com/art/201401/426252_all.htm