I have the following code that i need to alter to add additional time metrics such as:
Document Number, Status,
Time Elapsed Minutes, Created Date, Created Time, Accepted By Store,
Minutes To Accepted By Store, Invoiced At, Mins Elapsed, Invoiced,
Driver Accepted, Mins Driver Accepted, Driver At Store Mins Driving To Store,
,Mins Driver In Store, Driver Starts Delivery,
,Driver Arrival At Client,Mins Driving To Client,
Driver Completes Delivery,
Total Mins Elapsed To Delivery.
SELECT DATE(o.created_datetime) as Date, o.store_uid as 'Store UID'
, o.uid as 'Order'
, o.rating as 'Rating'
, IF(o.accepted_datetime < o.driver_ready_datetime, TRUE, FALSE) as 'Switch'
, timestampdiff(minute, o.created_datetime, o.accepted_datetime) as 'Accepted Order'
, if(accepted_datetime < driver_ready_datetime, timestampdiff(minute, o.accepted_datetime, o.driver_ready_datetime), timestampdiff(minute, o.created_datetime, o.driver_ready_datetime)) as'Invoiced Order'
, timestampdiff(minute, o.created_datetime, o.delivered_datetime) as 'Delivery Time'
, ROUND(if(o.amended_items_total IS NOT NULL, o.amended_items_total, o.items_total)
+ if(o.amended_bottles_fee IS NOT NULL, o.amended_bottles_fee, o.bottles_fee)
+ if(o.amended_delivery_fee IS NOT NULL, o.amended_delivery_fee, o.delivery_fee),2) as 'Turnover'
FROM `order` o
WHERE o.status = 'D' AND NOT store_uid IN (6,56, 202)
AND date(o.created_datetime) >= '2020-11-01'
Order Detail Template - for BI.xlsx