HIVE- lag函数和lead函数

 

select
date_flag
,category_flag
,field
,LAG(filed, 1) OVER (PARTITION BY category_flag ORDER BY date_flag) --同组前一个
,LEAD(filed, 1) OVER (PARTITION BY category_flag ORDER BY date_flag) --同组后一个
from table
;

 

posted @ 2022-02-17 17:48  冉溪  阅读(91)  评论(0编辑  收藏  举报