Galera eu tenho a seguinte query:
select a.*, b.* from
(
SELECT gm.Idaut AS IDIDA, gm.IdGuia AS GIDA,DATE_FORMAT(gm.Data,'%d/%m/%Y') as DATAI, gm.Viagem as ViagensI, gm.Turma as TURMAI, gm.Idcarro as CARROI, gm.IdLinha as LINHAI , gm.Sentido as IDA, DATE_FORMAT(gm.HoraSaida,'%H:%i') as SAIDAI, DATE_FORMAT(gm.HoraChegada,'%H:%i')as CHEGADAI, DATE_FORMAT(gm.Tempo,'%H:%i') as TEMPOI, gm.Passageiros as PAXI FROM guiasmov gm WHERE gm.Data = '2009-09-01' AND gm.Idcarro Between '100' AND '130' AND gm.IdLinha = 13 AND gm.Sentido = 0
)a,
(
SELECT g.Idaut AS IDVOLTA, g.IdGuia as GVOLTA,DATE_FORMAT(g.Data,'%d/%m/%Y') as DATAV, g.Viagem as ViagensV, g.Turma as TURMAV, g.Idcarro as CARROV, g.IdLinha as LINHAV, g.Sentido as VOLTA, DATE_FORMAT(g.HoraSaida,'%H:%i') as SAIDAV, DATE_FORMAT(g.HoraChegada,'%H:%i') as CHEGADAV, DATE_FORMAT(g.Tempo,'%H:%i') as TEMPOV, g.Passageiros as PAXV FROM guiasmov g WHERE g.Data = '2009-09-01' AND g.Idcarro Between '100' AND '130' AND g.IdLinha = 13 AND g.Sentido = 1
)b
WHERE b.ViagensV = a.ViagensI and b.TURMAV = a.TURMAI AND b.GVOLTA = a.GIDA
ORDER BY SAIDAI
Que me tras o seguinte resultado
LINHA VEÍCULO INTERV PARTIDA CHEGADA TEMPO PASSAG
XXXA 44455 00:00 04:55 05:10 00:55 39
XXXA 44444 00:00 05:28 06:30 01:02 43
XXXA 11111 00:00 05:36 06:32 00:56 39
Queria calcular a o intervalo entre os horarios de partida, que deveria ficar assim:
LINHA VEÍCULO INTERV PARTIDA CHEGADA TEMPO PASSAG
XXXA 44455 00:00 04:55 05:10 00:55 39
XXXA 44444 00:33 05:28 06:30 01:02 43
XXXA 11111 00:08 05:36 06:32 00:56 39
Algue tem idéia de como posso fazer isso ?
Abraços,
Leandro