1SELECT DATEADD(MINUTE, DATEDIFF(MINUTE, '2000', aa.[date]) / 10 * 10, '2000')
2 AS [date_truncated],
3 COUNT(*) AS [records_in_interval],
4 AVG(aa.[value]) AS [average_value]
5FROM [friib].[dbo].[archive_analog] AS aa
6-- WHERE aa.[date] > '1900-01-01'
7GROUP BY DATEADD(MINUTE, DATEDIFF(MINUTE, '2000', aa.[date]) / 10 * 10, '2000')
8ORDER BY [date_truncated]
9