题解 | #10月的新户客单价和获客成本#

10月的新户客单价和获客成本

http://www.nowcoder.com/practice/d15ee0798e884f829ae8bd27e10f0d64

select round(avg(total_amount),1) avg_amount,round(avg(cost),1) 
from (
select distinct order_id,total_amount,sale_price-total_amount cost 
  from  tb_product_info t1 #去重
left join 
(select t.order_id,event_time,product_id,uid,dense_rank()over(partition by uid order by event_time) rk,total_amount,
 sum(price)over(partition by t.order_id) sale_price from tb_order_detail t
left join  tb_order_overall  t_1 on t.order_id=t_1.order_id) t2     #按排序找首单,统计每个订单总售价。   
on t1.product_id=t2.product_id
where rk =1 and date(event_time) like '2021-10%' #按题意筛选首单以及2020年10月
) a



全部评论

相关推荐

真烦好烦真烦:牛友太有实力了
点赞 评论 收藏
分享
04-13 18:10
门头沟学院 Java
想熬夜的小飞象在秋招:被腾讯挂了后爸妈以为我失联了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务