GREATEST
eg:获取所有记录中,两个字段的最大值:
SELECT
MAX(shang_times) AS shang,
MAX(xia_times) AS xia,
MAX(GREATEST(shang_times,xia_times)) AS max
FROM times_tb WHERE id = 2744;
LEAST
eg:获取所有记录中,两个字段的最小值:
SELECT
MIN(shang_times) AS shang,
MIN(xia_times) AS xia,
MIN(LEAST(shang_times,xia_times)) AS min
FROM times_tb WHERE id = 2744;