• hive_连续天次计算


    drop table sospdm.tmp_yinfei_yuanzuan_redbag;
    create table sospdm.tmp_yinfei_yuanzuan_redbag stored as rcfile as
    select member_no,red_amount,process_time as min_date,date_add(process_time,diffdate-1) as max_date,diffdate from 
    (
        select member_no,red_amount,process_time,diffdate,row_number() over(partition by member_no order by diffdate desc ) as rk 
        from 
        (
            select
                 member_no,red_amount,process_time,diffdate
                ,row_number() over(partition by member_no,red_amount,process_time order by diffdate) as rn
            from 
            (
                select 
                     t1.member_no,t1.red_amount,t1.process_time,datediff(t2.process_time,t1.process_time)+1 as diffdate
                from 
                (
                    select member_no,sum(red_amount) as red_amount,to_date(process_time) as process_time
                    from sosp_ssa.xxx
                    where to_date(process_time)>='2018-12-20' and to_date(process_time)<='2019-01-20' and activity_id = '1212draw'
                    group by member_no,to_date(process_time)
                ) t1 
                inner join
                (
                    select member_no,sum(red_amount) as red_amount,to_date(process_time) as process_time
                    from sosp_ssa.xxx
                    where to_date(process_time)>='2018-12-20' and to_date(process_time)<='2019-01-20' and activity_id = '1212draw'
                    group by member_no,to_date(process_time)
                ) t2
                on t1.member_no=t2.member_no
                where datediff(t2.process_time,t1.process_time) >= 0
            ) t3
        ) t4 where diffdate = rn and rn >= 7
    ) t5 where rk = 1;
  • 相关阅读:
    iOS14
    iOS 音量键翻页实现
    pod 相关写法
    js 递归树结构数据查找指定元素的所有父级
    前端实现访问一个图片URL直接下载该图片
    HTML5 drag api 的使用
    vue 组件的 patch
    centos7安装nginx
    nginx常用配置说明
    遍历删除
  • 原文地址:https://www.cnblogs.com/yin-fei/p/10752043.html
Copyright © 2020-2023  润新知