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

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

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

with a as(
select * from (
select *, row_number()over(partition by uid order by event_time asc) as rn from tb_order_overall
) z
where rn = 1 and year(event_time) = 2021 and month (event_time) = 10),

b as(select order_id, sum(price*cnt) as 总价 from tb_order_detail
group by order_id)

select round(sum(a.total_amount)/count(*) , 1) as 首单平均交易金额, round((sum(b.总价) - sum(a.total_amount))/count(*), 1) as 平均获客成本
from a left join b 
on a. order_id = b.order_id


全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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