select CAST(AVG(dt) AS UNSIGNED) as gap
from (select abs(timestampdiff(second,o.logtime,s.logtime)) as dt
from order_log o join select_log s on o.order_id=s.order_id) a 

avg本身是浮点型,所以最后出来的结果会保留小数, 用CAST(AVG(dt) AS UNSIGNED) 来转换。cast会截断小数部分, as UNSIGNED只是指定截断后的类型, signed也是可以的。