hive 同一个表不同分区的数据求和
来源:互联网 发布:网络信息抓取软件 合法 编辑:程序博客网 时间:2024/05/29 04:36
业务表如下:
hive> desc sc_kekaoxing;OKid string 可靠小表id car_id string car表id month string 月份 name string 可靠名称父级 count string 可靠数量 dt string dp string # Partition Information # col_name data_type comment dt string dp string Time taken: 0.128 seconds, Fetched: 13 row(s)
hive> select * from sc_kekaoxing limit 5;OK1 10 201612 车身外观 5 201612 qiche1 11 201612 车身外观 6 201612 qiche1 12 201612 车身外观 7 201612 qiche1 13 201612 车身外观 2 201612 qiche1 14 201612 车身外观 17 201612 qicheTime taken: 0.386 seconds, Fetched: 5 row(s)
业务需求:不同dt分区下的字段count的值需要累加:
INSERT OVERWRITE local directory '/tmp/t01'row format delimited fields terminated by '\t'select if(aa.id is null,bb.id,aa.id),if(aa.car_id is null,bb.car_id,aa.car_id),'201702',if(aa.name is null,bb.name,aa.name),case when aa.count is not null and bb.count is not null then aa.count+bb.count when aa.count is null and bb.count is not null then bb.count when aa.count is not null and bb.count is null then aa.countelse 0 endfrom (select * from sc_kekaoxing where dt='201612') aa full outer join (select * from sc_kekaoxing where dt='201702') bb on aa.id=bb.id and aa.car_id=bb.car_id and aa.name=bb.name;
0 0
- hive 同一个表不同分区的数据求和
- 同一个服务器,不同表数据的复制
- hive表加载数据的不同方式
- hive建表语句(不同的数据存储格式,包括txt、orc、分区)
- 检查hive上的数据分区
- 改变Hive 表的分区
- Hive 修改表添加分区(add partition)和 加载数据时添加分区 的区别
- Hive中的数据分区
- Hive中的数据分区
- Hive中的数据分区
- hive不同分区不同存储格式
- [Hive]使用HDFS目录数据创建Hive表分区
- 同一个%的不同答案
- 同一个表中查询不同的数据,执行时间相差很远,是什么原因?
- 同一个用户在不同页面共享数据的常用方法
- ExtJS两个grid用同一个store显示不同的数据
- 同一个线程不同模块间的数据共享 ThreadLocal
- 同一个Activity中不同Fragment的数据传递
- Netty系列之Netty高性能之道
- 5年前端之路
- 2017年,电商、O2O项目怎样顺利拿到千万融资?
- 在php中用正则表达式删除img标签的width、height、style
- scala 实例——一
- hive 同一个表不同分区的数据求和
- IOS安装CocoaPods详情过程
- 如何定义和实现新的GObject之对象方法
- Hash冲突的解决方式
- Android之RecycleView和CardView
- Timer 在异步子线程 要放到 Runloop里才能使用
- 微信公众号开发
- 对最小生成树算法的理解
- lodash