select
cast(avg(abs(timestampdiff(second, o.logtime, s.logtime))) as signed) gap
from order_log o 
inner join select_log s
on o.order_id = s.order_id