如果数据为null则消除空间 [英] If data is null to eliminate space
本文介绍了如果数据为null则消除空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(Customer_first_name +''''+ Customer_middle_name +''''+ Customer_last_name)as CustomerName
如果Customer_middle_name为null
例如:
Customer_first_name = raj
Customer_middle_name = null
Customer_last_name = kumar
输出来了
raj(2个空格)kumar
但是我想要raj(1个空格)kumar
,以便Customer_middle_name为null以避免空间
(Customer_first_name +'' ''+Customer_middle_name +'' ''+Customer_last_name)as CustomerName
If Customer_middle_name is null
eg:
Customer_first_name=raj
Customer_middle_name=null
Customer_last_name=kumar
The output comes
raj (2 space)kumar
but i want raj (1 space)kumar
so that Customer_middle_name is null to avoid space
推荐答案
您可以使用COALESCE选择第一个非空值。所以在这种情况下类似
You can use COALESCE to select first non-null value. So in this case something like
COALESCE(Customer_first_name + ' ', '')
+ COALESCE(Customer_middle_name + ' ', '')
+ Customer_last_name AS CustomerName
这篇关于如果数据为null则消除空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文