小编Log*_*gan的帖子

SQL Hive - 将空值替换为 0 (Hadoop Hive)

进行左连接后,我留下了许多空值。如何仅在同一查询中的某些列中将这些空值替换为 0?

select 
    m1.*, t2.Apple, t3.Berry, t4.Cherry
from
    table1 as t1
    left join table2 as t2 on t1.id = t2.id
    left join table3 as t3 on t1.id = t3.id
    left join table3 as t4 on t1.id = t4.id
;
Run Code Online (Sandbox Code Playgroud)

示例输出

ID  Apple     Berry    Cheery
1   1         NULL     1
2   1         NULL     NULL
3   NULL      1        NULL
4   NULL      NULL     NULL
Run Code Online (Sandbox Code Playgroud)

sql hadoop hive left-join sql-null

3
推荐指数
1
解决办法
7346
查看次数

标签 统计

hadoop ×1

hive ×1

left-join ×1

sql ×1

sql-null ×1