SELECT fStart, fSourceName, fUser, fMeasurementTypeName FROM AutoSchedule LEFT JOIN Source USING (fSourceKey) LEFT JOIN MeasurementType USING (fMeasurementTypeKey) WHERE fStart BETWEEN ADDDATE('2024-12-18', INTERVAL +12 HOUR) AND ADDDATE('2024-12-18', INTERVAL +36 HOUR) ORDER BY fStart
SELECT fStart, fSourceName, fUser, fMeasurementTypeName FROM Schedule LEFT JOIN Source USING (fSourceKey) LEFT JOIN MeasurementType USING (fMeasurementTypeKey) WHERE fStart BETWEEN ADDDATE('2024-12-18', INTERVAL +12 HOUR) AND ADDDATE('2024-12-18', INTERVAL +36 HOUR) ORDER BY fStart
SELECT tmp.* FROM ( SELECT @numrow:=@numrow+1 AS '#', @sn AS 'Source', @sk AS 'S', @runmin, @runmax, @time, @datatime, @min, @max, TIMEDIFF(@max, @min) AS 'dt', fNight, if ((@sk!=fSourceKey && @sk!=-1) || @numrow=(SELECT COUNT(1) FROM RunInfo WHERE fNight=20241218 AND NOT fRunStart='0000-00-00 00:00:00' AND NOT fRunStop='0000-00-00 00:00:00' ORDER BY fRunID), 1, 0) AS bla, if (@sk!=fSourceKey, @min:=fRunStart, 0) AS '0', if (@sk!=fSourceKey, @runmin:=fRunID, 0) AS '1', if (@sk!=fSourceKey, @time:=TIMEDIFF(fRunStop, fRunStart), @time:=ADDTIME(@time, TIMEDIFF(fRunStop, fRunStart))) AS '2', if (@sk!=fSourceKey, if (fRunTypeKey=1, @datatime:=TIMEDIFF(fRunStop, fRunStart), @datatime:='00:00:00'), if (fRunTypeKey=1, @datatime:=ADDTIME(@datatime, TIMEDIFF(fRunStop, fRunStart)), 0)) as '7', @max:=fRunStop AS '3', @runmax:=fRunID AS '4', if (ISNULL(fSourceKey), @sk:=0, @sk:=fSourceKey) AS '5', if (ISNULL(fSourceKey), @sn:='n/a', @sn:=fSourceName) as '6' FROM RunInfo CROSS JOIN (SELECT @numrow:=0, @sn:='n/a', @sk:=-1, @runmin:=0, @runmax:=0, @time:=0, @datatime:=0, @min:=0, @max:=0) PARAMS LEFT JOIN Source using(fSourceKey) WHERE fNight=20241218 AND NOT fRunStart='0000-00-00 00:00:00' AND NOT fRunStop='0000-00-00 00:00:00' ORDER BY fRunID ) tmp WHERE bla>0