SELECT MAX(ApexSQL.FTruncateDate(MeasuredAt, [ApexSQL].[CalculateInterval](@StartDate, @EndDate, @Interval) )) as X , AVG(Value) as Y, MAX(@serie) as Serie ...
--Converts SQL Server agent status type to string (Stopped, Start pending, Stop pending, Running, Continue pending, Pause pending and Paused) ...