Oracle-利用解析函数计算连续、回流
---最大连续交易天数
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-利用解析函数计算连续、回流的更多相关文章
- Oracle计算连续天数,计算连续时间,Oracle连续天数统计
Oracle计算连续天数,计算连续时间,Oracle连续天数统计 >>>>>>>>>>>>>>>>> ...
- mysql计算连续天数,mysql连续登录天数,连续天数统计
mysql计算连续天数,mysql连续登录天数,连续天数统计 >>>>>>>>>>>>>>>>>& ...
- 虚拟机VMWARE上ORACLE License 的计算
Oracle License的计算有两种方式:按照用户数和CPU个数. 其中按CPU计算方式如下: License Number = The Number of CPU Cores * Core ...
- oracle 利用flashback将备库激活为read wirte(10g 及上)
oracle 利用flashback将备库激活为read wirte(10g 及上) 环境: OS: CENTOS 6.5 X64 DB: ORACLE 10.2.0.5 主库操作: SQL> ...
- 利用sklearn计算文本相似性
利用sklearn计算文本相似性,并将文本之间的相似度矩阵保存到文件当中.这里提取文本TF-IDF特征值进行文本的相似性计算. #!/usr/bin/python # -*- coding: utf- ...
- 计算连续的IP地址
题目:要求计算连续的IP地址. 举例:起始IP为192.168.2.2,IP总个数为3,那么要求得的所有IP的为192.168.2.2,192.168.2.3,192.168.2.4.再举个例子,起始 ...
- 利用Python计算π的值,并显示进度条
利用Python计算π的值,并显示进度条 第一步:下载tqdm 第二步;编写代码 from math import * from tqdm import tqdm from time import ...
- Ajax实例一:利用服务器计算
Ajax实例一:利用服务器计算 HTML代码 //输入两个数 <input id="number1" type="number"> <inpu ...
- 利用函数计算构建微信小程序的Server端
10分钟上线 - 利用函数计算构建微信小程序的Server端-博客-云栖社区-阿里云 https://yq.aliyun.com/articles/435430 函数计算 读写 oss import ...
随机推荐
- DRBD 数据镜像软件介绍
简介: DRBD (Distributed Replicated Block Device) 分布式块设备复制,是一种基于软件.网络的块复制存储解决方案.主要用于对服务器之间的磁盘.分区.逻辑卷等进行 ...
- Redis 非关系型数据库 ( Nosql )
简介: Redis 是一个开源的,高性能的 key-value 系统,可以用来缓存或存储数据. Redis 数据可以持久化,并且支持多种数据类型:字符串(string),列表(list),哈希(has ...
- win10 wsl安装 命令行
用于一些精简版没有商店的安装方法 开启"Windows Subsystem for Linux" 可选特性 打开`PowerShell`,运行下面指令: Enable-Window ...
- ubuntu linux常用指令(1)
序号 命令 说明 1 sudo su 从普通用户切换到root用户 2 su user 从root用户切换到普通用户 3 ls 列出当前目录的文件和目录,但是不包括隐藏文件和目录 4 ls -a 列出 ...
- 微信小程序相关三、css写小黄人
小程序上课第三天,因为今天院里有活动,所以没去上课,第四天上午又因为要召开入党转正大会,又耽误了一上午,下午去上课,要了资料.这两天讲了一些零零碎碎的东西,做的实例有上面这个小黄人 都是用的css,基 ...
- Mono在Full AOT模式下的限制
[Mono在Full AOT模式下的限制] 调试时遇到一个Mono运行时异常: ExecutionEngineException: Attempting to JIT compile method ' ...
- GC类
[GC类] GC是一个静态类. 垃圾回收器跟踪并回收托管内存中分配的对象.垃圾回收器定期执行垃圾回收以回收分配给没有有效引用的对象的内存.当使用可用内存不能满足内存请求时,垃圾回收会自动进行.或者,应 ...
- 文件上传控件asp:FileUpload
前端 使用的控件<asp:FileUpload ID="fileup" runat="server" /><span class=" ...
- springboot启动正常,访问restController报404
原因:spring boot只会扫描启动类当前包和以下的包 比如以下: 主类:Application放在包com.springboot.main controller类放在包com.springboo ...
- C++学习--第一个程序
C++控制台应用程序 我们创建一个包含预编译头的C++控制台应用程序时,会发现其结构是这样的: 1)理解预编译头文件: 所谓头文件预编译,就是把一个工程(Project)中使用的一些MFC标准头文件( ...