---最大连续交易天数
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. Oracle 与 MySQL 批量添加

    Oracle: <update id="createNew" statementType="STATEMENT" parameterType=" ...

  2. solr的简单部署:在tomcat中启动slor

    1,首先要下载solr 途径1: 官网网址: http://lucene.apache.org/ 与Lucene的官网是一个 途径2: 下载历史版本的网址: http://archive.apache ...

  3. VUE+WebPack游戏设计:欲望都市城市图层的设计

  4. 【LA3415 训练指南】保守的老师 【二分图最大独立集,最小割】

    题意 Frank是一个思想有些保守的高中老师.有一次,他需要带一些学生出去旅行,但又怕其中一些学生在旅行中萌生爱意.为了降低这种事情发生的概率,他决定确保带出去的任意两个学生至少要满足下面四条中的一条 ...

  5. 49. Group Anagrams同义词合并

    [抄题]: Given an array of strings, group anagrams together. Example: Input: ["eat", "te ...

  6. java读取properties配置文件[转]

    网上文章常见的几种读取.properties文件的方式 1.使用java.util.Properties类的load()方法 示例: InputStream in = lnew BufferedInp ...

  7. 最近工作的一点小tips

    最近工作比较忙,但也积累了一些小tips,比较杂,不成系统,也并不很深入,就开一篇笼统的先记录一下,以后再深入挖掘. 1.-webkit-tap-highlight-color -webkit-tap ...

  8. 冲刺NOIP2015提高组复赛模拟试题(五)2.道路修建

    2.道路修建 描述 Description liouzhou_101最悲痛的回忆就是NOI2011的道路修建,当时开了系统堆栈,结果无限RE… 出于某种报复心理,就把那题神奇了一下: 在 Z星球上有N ...

  9. windows关闭/开启休眠命令行

    C:\hiberfil.sys占用空间过大,可以考虑关闭休眠 powercfg -h off 重新开启 powercfg -h on

  10. 使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程

    在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...