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;

hive_连续天次计算的更多相关文章

  1. Oracle计算连续天数,计算连续时间,Oracle连续天数统计

    Oracle计算连续天数,计算连续时间,Oracle连续天数统计 >>>>>>>>>>>>>>>>> ...

  2. mysql计算连续天数,mysql连续登录天数,连续天数统计

    mysql计算连续天数,mysql连续登录天数,连续天数统计 >>>>>>>>>>>>>>>>>& ...

  3. python中建模分析零息票收益率曲线--复利和连续复利

    收益率曲线(Yield Curve)是显示一组货币和信贷风险均相同,但期限不同的债券或其他金融工具收益率的图表.纵轴代表收益率,横轴则是距离到期的时间.在此用python建模分析零息票收益率曲线,输出 ...

  4. 初识virtual memory

    一.先谈几个重要的东西 virtual memory是一个抽象概念,书上的原文是"an abstraction of main memory known as virtual memory& ...

  5. Theano2.1.10-基础知识之循环

    来自:http://deeplearning.net/software/theano/tutorial/loop.html loop 一.Scan 一个递归的通常的形式,可以用来作为循环语句. 约间和 ...

  6. 《C与指针》第四章练习

    本章问题 1.Is the following statement legal?If so,what does it do? (下面的语句是否合法,如果合法,它做了什么) 3 * x * x - 4 ...

  7. python 学习之电脑的发展历史

    电脑的发展历史 电脑的学名叫计算机,电脑是用来做计算的.在古时候,人们最早使用的计算工具可能是手指,英文单词“digit”既有“数字”的意思,又有“手指“的意思.古人用石头打猎,所以还有可能是石头来辅 ...

  8. OpenGL基础图形编程

    一.OpenGL与3D图形世界1.1.OpenGL使人们进入三维图形世界 我们生活在一个充满三维物体的三维世界中,为了使计算机能精确地再现这些物体,我们必须能在三维空间描绘这些物体.我们又生活在一个充 ...

  9. 用于分类的决策树(Decision Tree)-ID3 C4.5

    决策树(Decision Tree)是一种基本的分类与回归方法(ID3.C4.5和基于 Gini 的 CART 可用于分类,CART还可用于回归).决策树在分类过程中,表示的是基于特征对实例进行划分, ...

随机推荐

  1. (转)整理 node-sass 安装失败的原因及解决办法

    转载地址:https://segmentfault.com/a/1190000010984731

  2. ie.360,qq浏览器这种ie内核浏览器默认阻止弹窗

  3. SpringBoot实现异步

    1.创建AsyncTest类 package com.cppdy.service; import org.springframework.scheduling.annotation.Async; im ...

  4. py4j汉语转拼音多音字处理

    先看下效果 一 .布局 <!-- 上面的搜索框 --> <com.example.editablealphalist.widgget.ClearEditText android:id ...

  5. exec与match方法的区别

    http://www.cnblogs.com/xiehuiqi220/archive/2008/11/05/1327487.html var someText= "web2.0 .net2. ...

  6. 分布式通讯架构RPC简单实现

    什么是RPC: RPC(Remote Procedure Call,远程过程调用),一般用来实现部署在不同机器上的系统之间的方法调用,使得程序能够像访问本地系统资源一样,通过网络传输去访问远端系统资源 ...

  7. LeetCode(86):分隔链表

    Medium! 题目描述: 给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 x 的节点都在大于或等于 x 的节点之前. 你应当保留两个分区中每个节点的初始相对位置. 示例: 输入: hea ...

  8. mybatis的批量删除操作

    需求描述:将符合某条件的几条记录删除 解决思路:对于多个id,可以使用sql关键词 in ,只要满足数据库的id在你的id集合或者list中,就删除,从而实现批量删除.循环delete方法是在是low ...

  9. 【linux】centos6.9通过virtualenv安装python3.5

    参考:http://www.linuxidc.com/Linux/2015-08/121352.htm wget https://www.python.org/ftp/python/3.5.4/Pyt ...

  10. C# Parallel并发执行相关问题

    1.Parallel并发执行 using System;using System.Collections.Generic;using System.Linq;using System.Text;usi ...