with temp0 as ( select max(delivered_ts) as benchmark_day from parcel ), temp1 as ( select p.courier_id, count(*) as orders_7d, count(if(timestampdiff(minute,shipped_ts,delivered_ts)<=promised_minutes,1,null)) as on_time_7d, round(ifnull(count(if(timestampdiff(minute,shipped_ts,delivered_ts)<=...