题解 | #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

全部评论

相关推荐

死在JAVA的王小美:哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈,我也是,让我免了一轮,但是硬气拒绝了
点赞 评论 收藏
分享
我见java多妩媚:大外包
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务