select cast(avg(abs(timestampdiff(second,o.logtime,s.logtime))) as unsigned) as gap from order_log as o join select_log as s using(order_id)