select cast(cast(avg(abs(timestampdiff(second,s.logtime,o.logtime)))as decimal(5,0))as unsigned) as gap from order_log o left join select_log s on o.order_id=s.order_id