SELECT @id:=0;
SELECT
@id:=@id+1 as id,
A.`time`,
IFNULL(UNIX_TIMESTAMP(A2.`time`)-UNIX_TIMESTAMP(A.`time`), 0) as dura,
A.type
FROM A
LEFT JOIN A A2
ON A.id + 1 = A2.id
WHERE
MOD(A.id, 2) = 1
AND A.`time` BETWEEN '2013-01-01' AND '2014-01-01';