Hive序列函数&&排名函数

序列函数

ntile

sql 复制代码
# 获取一个表中,所有消费记录,每个人后50%的消费记录
with t as (
	select *,ntile(2) over(partition by name) xh from t_order
)
select * from t where xh = 2

lag & lead

sql 复制代码
# 获取上一次的消费记录

	select *,lag(orderdate,1,1900-01-01) over(partition by name order by orderdate) from t_order
sql 复制代码
# 5分钟,点击100次的用户

	select id,dt,lag(dt,100),

排名函数

1、row_numer() 没有并列

2、rank() 存在并列,存在空位

3、dense_rank() 存在并列,不存在空位

相关推荐
Irene19911 小时前
外部表(EXTERNAL_TABLE)Hive 借用数据,删表不删数据
hive·内部表·外部表
WL_Aurora21 小时前
Hadoop HA高可用架构深度解析
大数据·hadoop·架构
Irene19911 天前
Windows 11 WSL Ubuntu 环境:实际安装 Hive 踩坑实录
hive·windows·ubuntu
Irene19911 天前
Windows 11 WSL Ubuntu 环境:实际安装 Hadoop 踩坑实录
linux·hadoop·ubuntu
Irene19911 天前
(课堂笔记)Hive 分区、分桶与数据倾斜
hive·hadoop
Irene19912 天前
在 WSL Ubuntu 上安装和使用 Hive
linux·hive·ubuntu
二宝哥2 天前
大数据之安装Hadoop3.1.4
大数据·hadoop
Irene19912 天前
Windows 11 WSL Ubuntu 环境:安装 Hadoop 完整指南
hadoop·ubuntu
Irene19912 天前
(课堂笔记)Hive 基础
hive·hadoop