hive中多個字段拼接注意躲避空值

select concat(leix01,leix02,leix03) from dim_ivr_dictionary where ivr_table like 'zj%' and bm='40102';

select concat(nvl(leix01,''),nvl(leix02,''),nvl(leix03,'')) from dim_ivr_dictionary where ivr_table like 'zj%' and bm='40102'

若是三個字段都不爲空,能夠直接使用第一個語句獲取拼接字段code

若三個字段中包含空值,則使用第一個語句獲取的拼接字段爲空值,使用第二個語句纔可獲取正確拼接字段。io

切記拼接字段的時候使用nvl預防空值table

相關文章
相關標籤/搜索