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

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

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

with temp1 as(
select order_id,uid	,event_time,status,row_number()over(partition by uid order by event_time) rk,total_amount
from tb_order_overall),
temp2 as (
select order_id,uid	,total_amount
from temp1
where rk=1 and year(event_time) = 2021 and month(event_time) = 10 and status = 1),
temp3 as(
select order_id ,sum( price * cnt ) amount
from tb_order_detail
group by order_id)
select round(sum(total_amount)/count(order_id),1) avg_amount ,round(sum(amount-total_amount)/count(order_id),1) avg_cost
from temp2 join temp3 using(order_id)

全部评论

相关推荐

不愿透露姓名的神秘牛友
05-25 18:29
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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