(一)聚合函数
1、count 个数统计函数: count(*)
2、sum 总和统计函数:sum(score)
3、max 最大值统计函数:max(score)
4、min 最小值统计函数:min(score)
5、avg 平均值统计函数:avg(score)
(二)窗口函数
1、rank 考虑分组内数据的重复性,重复的会挤占后续的标号:
rank() over(partition by col1 order by col2
2、row_number 不考虑分组内数据的重复性
row_number() over(partition by col1 order by col2)
3、dense_rank 考虑分组内数据的重复性 重复的不会挤占后续的标号:
dense_rank() over(partition by col1 order by col2
(3)日期函数
1、unix_timestamp 获取当前UNIX时间戳函数:select unix_timestamp()
2、from_unixtime 日期函数UNIX时间戳转日期函数: from_unixtime(bigint unixtime[, string format])
3、unix_timestamp 日期转UNIX时间戳函数: unix_timestamp(string date, string pattern)
4、to_date 日期时间转日期函数:to_date(string timestamp)
select to_date(‘2019-06-28 16:02:03’)
5、datediff 日期比较函数:datediff(string enddate, string startdate)
select datediff(‘2019-06-28’,‘2019-05-28’)
(四)数学计算函数
1、abs 绝对值函数:abs(double a) abs(int a)
select abs(-3.9)
2、round 指定精度取整函数 :round(double a, i

本文介绍了Hive中的常用函数,包括聚合函数(如count、sum、max、min、avg)、窗口函数(rank、row_number、dense_rank)、日期函数(如unix_timestamp、from_unixtime、to_date等)、数学计算函数(如abs、round、floor、ceil、rand)以及字符串处理函数(如length、concat、md5、substr等)。此外,还提到了其他函数如cast、case when等,是Hive SQL操作的重要工具。
最低0.47元/天 解锁文章
1650

被折叠的 条评论
为什么被折叠?



