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

全部评论

相关推荐

hso_:哈哈哈哈哈哈我没offer一样在同一道题开喷了
投递深圳同为数码等公司10个岗位
点赞 评论 收藏
分享
面试摇了我吧:啊哈哈面试提前五个小时发,点击不能参加就是放弃
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务