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

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

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

这个题还是容易。

#题目描述看起来不需要考虑退单的情况

select
    format(avg(d.payment),1) as avg_amount,
    format(avg(d.realPrice-d.payment),1) as avg_cost
from
(
    select
        b.order_id,max(total_amount) as payment,sum(c.price*c.cnt) as realPrice
    from 
    (
        select
        a.order_id,a.uid,date_format(a.event_time,'%Y-%m-%d') as time,a.total_amount,row_number() over(partition by a.uid order by a.event_time) as rk
        from tb_order_overall a
    ) b join tb_order_detail c on b.rk = 1 and b.time >= '2021-10-01' and b.time <= '2021-10-31' and b.order_id = c.order_id
    group by b.order_id
) d

全部评论

相关推荐

11-09 01:22
已编辑
东南大学 Java
高级特工穿山甲:羡慕,我秋招有家企业在茶馆组织线下面试,约我过去“喝茶详谈”😢结果我去了发现原来是人家喝茶我看着
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务