函数替换配置单元SQL中的NULL或空值

函数替换配置单元SQL中的NULL或空值,sql,hadoop,select,hive,sql-update,Sql,Hadoop,Select,Hive,Sql Update,我有一个表,其中有两列是“customer\u name”和“customer\u name\u modified”。当“customer\u name\u modified”为空时,我是否可以在查询中编写一个函数,用“customer\u name\u modified”填充“customer\u name”值?您可以使用大小写表达式: select customer_name, case when customer_name_modified is null or custo

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

您可以使用
大小写表达式:

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 mytable
set customer_name_modified = customer_name
where customer_name_modified is null or customer_name_modified = '' 

您可以使用
大小写
表达式:

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 mytable
set customer_name_modified = customer_name
where customer_name_modified is null or customer_name_modified = ''