用Hive,计算每一年出现过的最大气温的日期+温度

数据格式: 2012010732 2012010812 .................... 2015011023 解题思路 1>将数据按日期和温度拆分开 创建表存放原始数据temperature.txt hive> create table if not exists myhive.temper(alldata string); hive> load data local inpath '/home/hadoop/temperature.txt' into table temper; 按年月日 温度拆分子串,日期存的时候按整数或日期格式存比较好,方便后面排序和输出 hive> create table temperature as select substr(alldata,1,4) year,substr(alldata,5,2) month,substr(alldata,7,2) day,substr(alldata,-2,2) tmp from temper;

输入图片说明

select int(f.year),collect_set(f.month)[0] month,collect_set(f.day)[0] day,max(f.tmp) from (select year,month,day,tmp from temperature order by year asc,tmp desc) f group by f.year;\n 输入图片说明 另外的解题思路: create table temperature1 as select concat_ws( '-', substr(alldata,1,4),substr(alldata,5,2), substr(alldata,7,2) ) as yearT,substr(alldata,-2,2) tmp from temper;

转载于:https://my.oschina.net/u/3730508/blog/1588121

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值