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

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

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

with tiaojian as (
select 
uid,
order_id,
total_amount
from(
select 
uid,
order_id,
total_amount,
date_format(event_time,"%Y%m") as month,
dense_rank()over(partition by uid order by date(event_time) ) as pn
from tb_order_overall
) as t 
where
month="202110"
and
pn=1
),tiaojian1 as (
select 
order_id,
sum(price) as tp
from tb_order_detail
group by order_id
)


select 
round(
avg(total_amount),1),
round(
avg(tp-total_amount),1)
from tiaojian t 
inner join tiaojian1 t1
on t.order_id=t1.order_id


全部评论

相关推荐

11-18 15:57
门头沟学院 Java
最终归宿是测开:这个重邮的大佬在重邮很有名的,他就喜欢打92的脸,越有人质疑他,他越觉得爽😂
点赞 评论 收藏
分享
爱看电影的杨桃allin春招:我感觉你在炫耀
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务