HQL一天一个小技巧:coalesce和nvl函数区别

coalesce 函数
COALESCE函数语法为COALESCE(表达式1,表达式2,...,表达式n),n>=2,此表达式的功能为返回第一个不为空的表达式,如果都为空则返回空值。 注意:所有表达式必须为同一类型或者能转换成同一类型。  
CREATE OR REPLACE VIEW v AS
SELECT NULL AS C1, NULL AS C2, 1 AS C3, NULL AS C4, 2 AS C5, NULL AS C6 FROM tmp
UNION ALL
SELECT NULL AS C1, NULL AS C2, NULL AS C3, 8 AS C4, NULL AS C5, 5 AS C6 FROM tmp;

SQL> select * from v;

C1 C2 C3 C4 C5 C6
- - ---------- ---------- ---------- ----------
1

HQL一天一个小技巧:coalesce和nvl函数区别最先出现在Python成神之路

版权声明:
作者:感冒的梵高
链接:https://www.techfm.club/p/13372.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>