如何在配置单元中忽略总和中的空值 [英] How to ignore null values in sum in hive
本文介绍了如何在配置单元中忽略总和中的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ID值
1
1
ID值
1
1 2
做总和我需要输出作为
select id,sum(val)from table group by id;
第一次输出
id sum
1
第二个表格输出
id sum
1 2
<在数学默认 2 + 0 = 2
中,所以无论如何它都可以工作。不要担心这个问题。 hive
将会默认会照顾到这一点。
hive>首先创建表(Id int,value int);
确定
所用时间:3.895秒
配置单元>从第一个选择*
OK
1 2
1 NULL
hive>选择id,sum(value)作为从第一个组开始的和;
Total MapReduce CPU使用时间:4秒610毫秒
确定
1 2
所需时间:83.483秒,提取:1行
I am having a table in hive with below values
ID value
1
1
ID value
1
1 2
while doing sum i need the output as
select id,sum(val) from table group by id;
first required output
id sum
1
Second table Output
id sum
1 2
解决方案
In math default 2+0=2
so its anyway going to work .Don't worry about this hive
will be default will take care this.
hive> create table first (Id int,value int);
OK
Time taken: 3.895 seconds
hive> select * from first;
OK
1 2
1 NULL
hive> select id, sum(value) as sum from first group by id;
Total MapReduce CPU Time Spent: 4 seconds 610 msec
OK
1 2
Time taken: 83.483 seconds, Fetched: 1 row(s)
这篇关于如何在配置单元中忽略总和中的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文