---最大连续交易天数
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. Page directive: illegal to have multiple occurrences of contentType with different values

    org.apache.jasper.JasperException: /commons/meta.jsp(1,1) PWC5988: Page directive: illegal to have m ...

  2. go unit test-monkey

    package main import ( "fmt" "github.com/bouk/monkey" "os" "os/exe ...

  3. java基础之日期时间工具类

    package zy.test; import java.sql.Timestamp; import java.text.ParseException; import java.text.ParseP ...

  4. 前Forward / 延时Deferred

    本章节描述了延时光照的渲染路径的细节,如果想了解延迟光照技术,请查阅Deferred Lighting Approaches article. Deferred Lighting is renderi ...

  5. Ros学习——movebase源码解读之amcl

    1.amcl的cmakelists.txt文件 add_executable(amcl  src/amcl_node.cpp) target_link_libraries(amcl amcl_sens ...

  6. 71. Simplify Path压缩文件的绝对路径

    [抄题]: Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/&q ...

  7. 解决table边框在打印中不显示的问题

    先了解一下,table边框如何设置 一.只对表格table标签设置边框 只对table标签设置border(边框)样式,将让此表格最外层table一个边框,而表格内部不产生边框样式.CSS代码: .t ...

  8. Nginx概述、安装及配置详解

    nginx概述 nginx是一款自由的.开源的.高性能的HTTP服务器和反向代理服务器:同时也是一个IMAP.POP3.SMTP代理服务器:nginx可以作为一个HTTP服务器进行网站的发布处理,另外 ...

  9. 3d点云与cad模型

    https://stackoverflow.com/questions/19000096/match-3d-point-cloud-to-cad-model

  10. 回顾2017系列篇(三):UX设计大会,都预示了哪些设计趋势

    2017已接近尾声,在这一年中,无数的UX大会和设计大会在世界各地召开.每一场会议的召开,都是界内精英人士经验的交流和智慧的碰撞.虽然2017年的会议都已过去,但每场会议上的话题探讨,尤其是界内精英们 ...