select round(avg(total_amount),1) as avg_amount ,round(avg(raw_amount-total_amount),1) as avg_cost from( select uid,sum(price*cnt) as raw_amount ,max(total_amount) total_amount from( select uid, date(event_time) event_day, total_amount,price,cnt, rank() over(partition by uid order by event_time) as ...