select round(avg(avg_a),1) avg_amount,round(avg(avg_in-avg_a),1) as avg_cost from
(select uid,avg(total_amount) avg_a,sum(cnt*price) avg_in from
(select uid,event_time,tod.order_id,total_amount,cnt,price
from tb_order_detail tod,tb_product_info tpi,tb_order_overall too
where tod.product_id=tpi.product_id and tod.order_id=too.order_id
and (uid,event_time) in (select uid,min(event_time) from tb_order_overall group by uid))a
where left(event_time,7) like '2021-10'
group by uid
order by uid)b