drop table if exists tmp_dw_dahai.fact_clue_state_log;
create table if not exists tmp_dw_dahai.fact_clue_state_log stored as parquet as
select
a.sale_id
,a.clue_id
,a.clue_status
,a.start_time
,from_unixtime(unix_timestamp(a.start_time)-60,'yyyy-MM-dd HH:mm:ss') as start_time_sub_60s
,a.end_time
,lead(a.clue_status,1) over(partition by a.sale_id,a.clue_id order by a.start_time) as next_sale_status --每个学规每个线索的下一个状态
,lead(a.clue_status,1) over(partition by a.clue_id order by a.start_time) as next_clue_status -- 每个线索的下一个状态
,row_number() over (partition by a.sale_id,a.clue_id order by a.start_time ) as num_sale_status
,row_number() over (partition by a.clue_id order by a.start_time ) as num_status
from dw_dahai.bas_clue_state_log a
left join (
select distinct a.clue_id
from
(select *,row_number() over (partition by clue_id,clue_status) num
from dw_dahai.bas_clue_
HIVE中窗口函数的使用
最新推荐文章于 2024-05-07 12:45:48 发布
这段博客介绍了如何在HIVE中使用窗口函数lead,通过示例展示了如何获取每个sale_id和clue_id的下一个状态,以及如何进行数据过滤,确保只保留有效状态流转记录。
摘要由CSDN通过智能技术生成