[英]DB2 NVL with empty string
与 DB2 中一样,空字符串和 null 与 Oracle 中不同。 有没有什么方法可以实现NVL但是空字符串?
您可以将它与NULLIF
结合使用:
如果两个参数相等,则 NULLIF 函数返回空值; 否则,它返回第一个参数的值。
SELECT NVL(NULLIF(col, ''),'replacement')
您可以使用case
表达式:
case when mycol = '' then 'some value' else mycol end
如果您还想处理null
值:
case when mycol = ''
or mycol is null
then 'some value'
else mycol
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.