SELECT
fNight AS '0',
TIME_TO_SEC(TIMEDIFF(fStopObservation, fStartObservation)) AS '1',
TIME_TO_SEC(TIMEDIFF(MAX(fRunStop),MIN(fRunStart))) AS '2',
SUM(IF (TIMEDIFF(fRunStop,fRunStart)<'00:30:00', TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)), 0)) AS '3',
SUM(IF (TIMEDIFF(fRunStop,fRunStart)<'00:30:00' AND fRunTypeKey=1, TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart)), 0)) AS '4'
FROM ObservationTimes
LEFT JOIN RunInfo USING(fNight)
WHERE fNight<DATE_FORMAT(DATE(NOW()), '%Y%m%d')
GROUP BY fNight
ORDER BY fNight
[3]< 0 : Array
(
[0] => 20130526
[1] => 29747
[2] => 23988
[3] => -632
[4] => -1895
)
[4]< 0 : Array
(
[0] => 20130526
[1] => 29747
[2] => 23988
[3] => -632
[4] => -1895
)
[4]< 0 : Array
(
[0] => 20130527
[1] => 29681
[2] => 24456
[3] => 699
[4] => -3930
)
[3]>[2]: Array
(
[0] => 20130808
[1] => 31734
[2] => 53369
[3] => 31878
[4] => 26677
)
[3]>[2]: Array
(
[0] => 20131003
[1] => 37694
[2] => 75739
[3] => 38229
[4] => 29939
)
[3]>[2]: Array
(
[0] => 20131006
[1] => 37995
[2] => 72045
[3] => 38466
[4] => 29905
)
[3]>[2]: Array
(
[0] => 20131009
[1] => 38291
[2] => 40829
[3] => 38666
[4] => 30503
)
[3]>[2]: Array
(
[0] => 20170711
[1] => 29451
[2] => 32385
[3] => 30464
[4] => 26627
)