---最大连续交易天数
select t2.customer_no,max(t2.co)
from
(select
t1.customer_no,t1.yp-t1.rn rk,count(1) co
from (select ctd.customer_no,
ctd.order_time yp,
row_number() over(partition by ctd.customer_no order by ctd.order_time) rn
from posp_boss.customer_trans_day ctd
where ctd.order_time >= to_date('', 'yyyymmdd')
order by ctd.customer_no,ctd.order_time)t1
group by t1.customer_no,t1.yp-t1.rn)t2
group by t2.customer_no
---计算回流状况
with t1 as
(select ctd.customer_no,
ctd.order_time yp,
row_number() over(partition by ctd.customer_no order by ctd.order_time) rn
from posp_boss.customer_trans_day ctd
where ctd.order_time >= to_date('', 'yyyymmdd')
order by ctd.customer_no,ctd.order_time) select t1.customer_no,max(ceil(t2.yp-t1.yp)) ypc
from
(select t1.customer_no,t1.yp,t1.rn-1 rm
from t1) t2
left join t1 on t1.customer_no = t2.customer_no and t1.rn = t2.rm
group by t1.customer_no
---计算回流涉及天数,商户,交易量
with t1 as
(select ctd.customer_no,
ctd.order_time yp,
row_number() over(partition by ctd.customer_no order by ctd.order_time) rn
from posp_boss.customer_trans_day ctd
where ctd.order_time >= to_date('', 'yyyymmdd')
order by ctd.customer_no,ctd.order_time) select
t3.ypc,
count(distinct t3.customer_no) mt,
sum(t4.amt) amount
from
(select t1.customer_no,max(ceil(t2.yp-t1.yp)) ypc
from
(select t1.customer_no,t1.yp,t1.rn-1 rm
from t1) t2
left join t1 on t1.customer_no = t2.customer_no and t1.rn = t2.rm
group by t1.customer_no)t3
join
(select ctd.customer_no,
sum(ctd.trans_amount) amt
from posp_boss.customer_trans_day ctd
where ctd.order_time >= to_date('', 'yyyymmdd')
group by ctd.customer_no)t4 on t3.customer_no = t4.customer_no
group by t3.ypc

Oracle-利用解析函数计算连续、回流的更多相关文章

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

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

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

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

  3. 虚拟机VMWARE上ORACLE License 的计算

    Oracle License的计算有两种方式:按照用户数和CPU个数. 其中按CPU计算方式如下: License Number = The Number of CPU Cores  *  Core ...

  4. oracle 利用flashback将备库激活为read wirte(10g 及上)

    oracle 利用flashback将备库激活为read wirte(10g 及上) 环境: OS: CENTOS 6.5 X64 DB: ORACLE 10.2.0.5 主库操作: SQL> ...

  5. 利用sklearn计算文本相似性

    利用sklearn计算文本相似性,并将文本之间的相似度矩阵保存到文件当中.这里提取文本TF-IDF特征值进行文本的相似性计算. #!/usr/bin/python # -*- coding: utf- ...

  6. 计算连续的IP地址

    题目:要求计算连续的IP地址. 举例:起始IP为192.168.2.2,IP总个数为3,那么要求得的所有IP的为192.168.2.2,192.168.2.3,192.168.2.4.再举个例子,起始 ...

  7. 利用Python计算π的值,并显示进度条

    利用Python计算π的值,并显示进度条  第一步:下载tqdm 第二步;编写代码 from math import * from tqdm import tqdm from time import ...

  8. Ajax实例一:利用服务器计算

    Ajax实例一:利用服务器计算 HTML代码 //输入两个数 <input id="number1" type="number"> <inpu ...

  9. 利用函数计算构建微信小程序的Server端

    10分钟上线 - 利用函数计算构建微信小程序的Server端-博客-云栖社区-阿里云 https://yq.aliyun.com/articles/435430 函数计算  读写 oss import ...

随机推荐

  1. Ryu控制器学习

    Ryu 在Mininet环境下实现Ryu为控制器控制ARP报文的实验中学习了Ryu相关的知识,记录如下 官方文档:http://ryu.readthedocs.io/en/latest/getting ...

  2. fatal error C1083: 无法打开包括文件:“iostream.h”: No such file or directory

    其实 <iostream.h>是c风格的,你可用,但注意格式:  要么是:  #include <iostream>  using namespace std; 在标准C++里 ...

  3. Spring DI的配置使用

    1.1.1 依赖和依赖注入Spring IOC容器的依赖有两层含义:Bean依赖容器和容器注入Bean的依赖资源:a.Bean依赖容器:也就是说Bean要依赖于容器,这里的依赖是指容器负责创建Bean ...

  4. JRE,JVM,JDK

    JRE,JVM,JDK的关系.JRE(Java Runtime Environment)java运行环境,我们可以把它看成是一个操作系统.也就是说JRE提供了Java执行的软件平台. JVM (Jav ...

  5. 【总结整理】UGC内容

    除了内容了产品,还有什么适合引入UGC? :引发讨论,诱导参与,然后促成销售. User Generated Content,也就是用户生成内容的意思. 购买类产品,内容催生购买 1.为用户购买提供思 ...

  6. Codeforces 712D DP

    题意:有2个人玩游戏,他们都有个初始值a和b, 游戏进行t轮, 每次可以选择加上一个[-k, +k]之间的数字,问有多少种方案a的和严格大于b的和. 思路:如果不考虑多于这个条件,只是询问有多少种方案 ...

  7. 274. H-Index论文引用量

    [抄题]: Given an array of citations (each citation is a non-negative integer) of a researcher, write a ...

  8. Python遍历一个文件夹下有几个Excel文件及每个Excel文件有几个Sheet

    一. 解决问题: 工作中常会遇到合并Excel文件的需求,Excel文件数量不确定,里面的Sheet 数量是可变的,Sheet Name是可变的,所以,需要用到遍历一个文件夹下有几个Excel文件,判 ...

  9. RTX二次开发::检索 COM 类工厂中 CLSID 为 {79210E58-99EB-45D0-8890-763EFEAA143F} 的组件失败,

    解决方法: 1.Interop.RTXSAPILib.dll这个是32位的 将IIS 应用程序池 启用32位应用程序 设置为true就可以了, 2.把编译好的程序选择X86平台运行,就好了 程序员的基 ...

  10. debian 9 更换源 使用国内源 配置方法

    配置前请先参考: https://wiki.debian.org/SourcesList https://www.debian.org/mirror/list https://mirrors.tuna ...