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

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

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

select
round(sum(b.total_amount)/count(b.uid),1) avg_amount,
round(sum(b.price)/count(b.uid),1) avg_cost
from
(
select 
a.uid,
max(too.total_amount) total_amount,
sum(tod.price)-max(too.total_amount) price
from 
(
select 
uid,
min(event_time) event_time
from tb_order_overall
group by uid
having month(min(event_time))=10 and year(min(event_time))=2021
) a
left join tb_order_overall too
on  too.uid=a.uid and too.event_time=a.event_time
left join tb_order_detail tod on too.order_id=tod.order_id
group by a.uid) b

全部评论

相关推荐

挣K存W养DOG:我记得好多人说这个公司就是白嫖方案的,现在有大体方案要让你给他展示实现细节了,也是无敌了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务