1、greatest函数:
greatest(col_a, col_b, ..., col_n)比较n个column的大小,过滤掉null或对null值进行处理,当某个column中是string,而其他是int/double/float等时,返回null;
举例:
select greatest(1, 2, 3, 4) --4
select greatest(-1, 1, 2, 3, null) --null
select greatest(-1, 1, 2, 3, "aaaa") --null
select greatest("2024-08-11","2024-08-12","2024-08-13") --2024-08-13
select greatest("2024-08-11 16:11:11","2024-08-12 17:17:17","2024-08-13 18:18:18") --2024-08-13 18:18:18
2、least函数:
select least(-1, 1, 2, 3) -- -1
select least(-1, 1, 2, 3, null) --null
select least(-1, 1, 2, 3, "aaaa") --null
select least("2024-08-11","2024-08-12","2024-08-13") --2024-08-11
select least("2024-08-11 16:11:11","2024-08-12 17:17:17","2024-08-13 18:18:18") --2024-08-11 16:11:11