SQL coalesce, if null (), nvl 函数

1. coalesce函数

coalesce(expr1, expr2, ...) - Returns the first non-null argument if exists. Otherwise, null.
返回所有参数中第一个非null的,若均为null,返回null。

SELECT coalesce(NULL, NULL,1);

SELECT coalesce(NULL, NULL);

2. nvl函数

nvl(expr1, expr2) - Returns expr2 if expr1 is null, or expr1 otherwise.

SELECT nvl(NULL, array('2'));

SELECT nvl(array('1'), array('2'))

3. ifnull函数

ifnull(expr1, expr2) - Returns expr2 if expr1 is null, or expr1 otherwise.

和nvl函数一致。

posted @ 2023-04-12 17:43  ttttttian  阅读(69)  评论(0)    收藏  举报