标签:max style 1.2 ble cas sele sql where 截取
Hive 通过 substr() 函数实现最高气温统计
将一行文本加载为 String
通过 substr() 函数截取年份和温度
1. 创建 temp 表
create table temp(line string);
2. 加载气温数据到 temp 表中
load data local inpath ‘/home/centos/files/temp‘ into table temp;
3. 编写 SQL 语句
select year, max(temperature) from (select substr(line,16,4) as year, cast(substr(line,88,5) as int) as temperature from temp) a where temperature != 9999 group by year;
类型转换 cast(temperature as int);
标签:max style 1.2 ble cas sele sql where 截取
原文地址:https://www.cnblogs.com/share23/p/10224093.html