Mysql: Calculate Time Difference Between Two Rows

planer_idplaner_start planer_end (order by planer_end)12016-08-06 04:00:002016-08-06 06:00:0022016-08-06 09:00:002016-08-06 12:00:0042016-08-06 17:00:002016-08-06 22:00:0052016-08-06 23:00:002016-08-07 04:00:0062016-08-07 06:00:002016-08-07 11:00:0032016-08-07 13:00:002016-08-07 20:00:00
SELECT T1.planer_id,T1.planer_start,T1.planer_end,MIN(T2.planer_start) as NEXT,TIMEDIFF(T1.planer_end,T1.planer_start) as Working,IFNULL(TIMEDIFF(MIN(T2.planer_start),T1.planer_end),'0') as DelayFROM TABLE AS T1LEFT JOIN TABLE AS T2 ONT2.planer_start > T1.planer_endGROUP BY T1.planer_id ORDER BY planer_start
[0] => Array ( [planer_id] => 1 [planer_start] => 2016-08-06 04:00:00 [planer_end] => 2016-08-06 06:00:00 [NEXT] => 2016-08-06 09:00:00 [Working] => 02:00:00 [Delay] => 03:00:00 )
 [1] => Array ( [planer_id] => 2 [planer_start] => 2016-08-06 09:00:00 [planer_end] => 2016-08-06 12:00:00 [NEXT] => 2016-08-06 17:00:00 [Working] => 03:00:00 [Delay] => 05:00:00 )
[2] => Array ( [planer_id] => 4 [planer_start] => 2016-08-06 17:00:00 [planer_end] => 2016-08-06 22:00:00 [NEXT] => 2016-08-06 23:00:00 [Working] => 05:00:00 [Delay] => 01:00:00 )
[3] => Array ( [planer_id] => 5 [planer_start] => 2016-08-06 23:00:00 [planer_end] => 2016-08-07 04:00:00 [NEXT] => 2016-08-07 06:00:00 [Working] => 05:00:00 [Delay] => 02:00:00 )
[4] => Array ( [planer_id] => 6 [planer_start] => 2016-08-07 06:00:00 [planer_end] => 2016-08-07 11:00:00 [NEXT] => 2016-08-07 13:00:00 [Working] => 05:00:00 [Delay] => 02:00:00 )
[5] => Array ( [planer_id] => 3 [planer_start] => 2016-08-07 13:00:00 [planer_end] => 2016-08-07 20:00:00 [NEXT] => [Working] => 07:00:00 [Delay] => 0 )