![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
sql
文章平均质量分 55
longduohongchen
这个作者很懒,什么都没留下…
展开
-
拉链表实现
每日全量跑批 select id, status, start_time, nvl(date_sub(next_time,1),'9999-12-31') as endtime from (select id, status, updatetime as start_time, lead(updatetime,1,null) over (partition by id order by updatetime) as next_time from order) tmp原创 2021-01-27 12:31:01 · 160 阅读 · 0 评论 -
补数据逻辑
1。先分组entid,对日期进行排序 self_rn 2。然后根据entid,(空值,非空值)分组,对时间排序(主要是求出空值分组内的日期排序)字段 为 null_rn 3。根据entid,(self_rn-null_rn排序(空值的情况下),非空赋值负数) 排序得出步长 4。自关联,如果非空,取本身。空值,减步长之后自关联,取关联的值。 with t as ( select entid, `month`, val, self_rn, row_number() over(partition by ent原创 2020-12-07 16:08:47 · 184 阅读 · 0 评论