NULL转其他
null转其他:
- 如果在分组和查询中都加nvl(A,'其他'),只会显示一个值,都为其他
 - 如果在分组中未加nvl(A,'其他'),只在查询中加nvl(A,'其他'),会显示两个值,分别为NULL和其他,只是展示时NULL转为其他
 
-- NULL转其他,分组和查询中都加nvl(A,'其他'),只显示一条数据
select
    nvl(activation_subclass,'其他') as activation_subclass,    -- 一级渠道
    nvl(activation_channel,'其他') as activation_channel     -- 明细渠道 (三级渠道)
fro***utocar.autocar_mds_user_by_device_distinct
where
    date <= '${date}'
    and is_background = 0
group by
    nvl(activation_subclass,'其他'),
    nvl(activation_channel,'其他') 
-- NULL转其他,分组中未加nvl(A,'其他'),只在查询中加nvl(A,'其他'),会显示两个值
select
    nvl(activation_subclass,'其他') as activation_subclass,    -- 一级渠道
    nvl(activation_channel,'其他') as activation_channel     -- 明细渠道 (三级渠道)
fro***utocar.autocar_mds_user_by_device_distinct
where
    date <= '${date}'
    and is_background = 0
group by
    activation_channel,
    activation_subclass 
vivo公司氛围 351人发布
查看3道真题和解析