题解 | #10月的新户客单价和获客成本#
10月的新户客单价和获客成本
http://www.nowcoder.com/practice/d15ee0798e884f829ae8bd27e10f0d64
select round(avg(t1.total_amount),1) avg_amount, round(avg(t1.total_price - t1.total_amount),1) avg_cost from ( select t_o.uid, t_o.total_amount, t_o.order_id, t.total_price from tb_order_overall t_o join (select order_id, sum(price * cnt) total_price from tb_order_detail group by order_id) t on t_o.order_id = t.order_id where date_format(event_time,'%Y-%m') = '2021-10'and (t_o.uid,t_o.event_time) in (select uid,min(event_time) from tb_order_overall group by uid) )t1