复购率/回购率/新购人数
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                复购率/回购率/新购人数
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                1. 回購率
#回購率第一步
select date_month,userid from orderr group by date_month,userid order by date_month這里不論1號(hào)用戶在本月購買多少次,只要購買就1,否則就0
#回購率第二步
select t1.date_month,count(t1.date_month),count(t2.date_month) from (select date_month,userid from orderr group by date_month,userid) t1 left join (select date_month,userid from orderr group by date_month,userid) t2 on t1.userid=t2.userid and month(t1.date_month) - month(t2.date_month) = 1 group by t1.date_month這一步把第一步的表內(nèi)連接,兩表相連,月份聚合,計(jì)算總?cè)藬?shù),和回購人數(shù)
2. 復(fù)購率
#復(fù)購第一步
select userid,date_month,count(distinct orderid) ct from orderr group by userid,date_month這一步注意1號(hào)用戶購買了2筆訂單,但是有一筆訂單是組合商品,即一個(gè)訂單中包括兩個(gè)商品100和200,所以一共顯示3條,聚合的時(shí)候不要把orderid聚合,因?yàn)橐延唵稳ブ睾笙嗉?#xff0c;得到本月購買次數(shù)總和,count(distinct orderid)
#復(fù)購第二步
select date_month,count(1) sm,count(if(ct>1,1,null)) from (select userid,date_month,count(distinct orderid) ct from orderr group by userid,date_month order by userid,orderid) t group by date_month3. 每月新購人數(shù)
select userid, min(date_month) as firstmon from `orderr` group by userid
 第一步先求出每個(gè)用戶的首購月份,一個(gè)用戶對(duì)應(yīng)一個(gè)月份
 求和的時(shí)候count(userid)就是新增用戶,因?yàn)橐粋€(gè)用戶對(duì)應(yīng)一個(gè)月份
完
總結(jié)
以上是生活随笔為你收集整理的复购率/回购率/新购人数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: AI绘画绘图流量主小程序开发
- 下一篇: tinode客户端安卓版编译手账
