hadoop—用于替换配置单元sql中的null或空值的函数

yrwegjxp  于 2021-05-31  发布在  Hadoop
关注(0)|答案(1)|浏览(281)

我有一个表,其中两列是“customer\u name”和“customer\u name\u modified”。当“customer\u name\u modified”为空时,我是否可以在查询中编写一个函数,将“customer\u name\u modified”值填充为“customer\u name”?

pgky5nke

pgky5nke1#

你可以使用 case 表达式:

select
    customer_name,
    case when customer_name_modified is null or customer_name_modified = '' 
        then customer_name 
        else customer_name_modified 
    end customer_name_modified 
from mytable

如果你在找一个 update 声明:

update mytable
set customer_name_modified = customer_name
where customer_name_modified is null or customer_name_modified = ''

相关问题