GREATEST和LEAST
SELECT GREATEST(25, 6, 7, 10, 20, 54); -- returns 54
SELECT LEAST(25, 6, 7, 10, 20, 54); -- returns 6
SELECT GREATEST('D','A', 'B', 'C','d','e','E'); -- returns 'E'
SELECT LEAST('D','A', 'B', 'C','d','e','E','a'); -- returns 'a'
SELECT GREATEST(6, NULL); -- result: 6
SELECT LEAST(6, NULL); -- result: 6
GREATEST和MAX的区别
MAX为 聚合函数
,在一个数据表的某一字段列中,取出最大值数据
PostgreSQL GREATEST & LEAST https://www.yetaozi.cn/postgresql/greatest-least-function