select cast(round(avg(abs(timestampdiff(second,t.logtime,t1.logtime))),0) as signed) as gap from order_log t join select_log t1 on t.order_id=t1.order_id and t.uid=t1.uid