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

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

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

select round(sum(total)/count(distinct uid),1) as avg_amount
,round((sum(act)-sum(total))/count(distinct uid),1) as avg_cost
from(# 条件过滤:2021-10新增用户及该用户2021-10期间订单的首单
    select 
    uid,avg(total_amount) as total,sum(price*cnt) as act
    from (#表关联,求用户首次日期和付款订单过滤
        select uid
        ,date(event_time) as dt 
        ,min(date(event_time)) over(partition by uid) as first_dt
        ,dense_rank() over(partition by uid order by event_time ) as rn  #首单标签
        ,total_amount
        ,price,cnt
        from tb_order_overall t1
        join tb_order_detail t2 on t1.order_id=t2.order_id
        where t1.status=1
    ) t
    where date_format(first_dt,'%Y-%m')='2021-10' 
    and date_format(dt,'%Y-%m')='2021-10'
    and rn =1
    group by uid
) tt

全部评论

相关推荐

07-03 11:02
中山大学 C++
字节刚oc,但距离九月秋招很近了有两段互联网实习,非腾讯字节。不敢赌转正,现在在纠结去还是不去如果实习俩月离职会有什么后果吗
阿城我会做到的:不去后悔一辈子,能否转正取决于ld的态度,只要他不卡,答辩就是走流程,个人觉得可以冲一把
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
程序员牛肉:主要是因为小厂的资金本来就很吃紧,所以更喜欢有实习经历的同学。来了就能上手。 而大厂因为钱多,实习生一天三四百的就不算事。所以愿意培养你,在面试的时候也就不在乎你有没有实习(除非是同级别大厂的实习。) 按照你的简历来看,同质化太严重了。项目也很烂大街。 要么换项目,要么考研。 你现在选择工作的话,前景不是很好了。
点赞 评论 收藏
分享
在喝茶的牛油很喜欢吃...:今天oc了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务