hive学习03-求一年中的最大温度

知识点:

substr、concat函数的使用:

row_number() over(distribute by year sort by temp desc)  #按照年分组,按照tmp去排序 

需求:现有hive表temp,其中只有一个字段(temp_record string),每一行代表某一天的气温,比如,2014010114代表,2014年1月1日的气温为14度,表中数据如下:

要求:用hive求出每一年的最大气温那条记录
注意:数据格式不能改变,例如求出来2015年的最大气温那条记录为2015010999


select concat(t2.years,t2.month_day,t2.day_weather)
from
(select t1.years,t1.month_day,t1.day_weather,
row_number() over(distribute by t1.years sort by t1.day_weather desc) as index
from
(select substr(line,1,4)years,substr(line,5,4)month_day,substr (line,9)day_weather
from weather)t1
)t2
where t2.index=;
上一篇:Django请求响应对象


下一篇:【5】基于Log4Net的日志系统