Someone may come and give you an answer with the full code, but the way I approach it is to break it down into several smaller tasks / solutions:
(1) Create a temporary table at intervals. See the accepted answer to this question:
Get a list of dates between two dates
This answer was for MySQL, but you need to get started. Googling "SQL Interval Creation" should also provide additional ways to do this. You want to use MAX (DateTime) and MIN (DateTime) from your main table as input to any method you use (and obviously 10 seconds for a range).
(2) Join the temp table with your main table with the join condition (pseudocode):
FROM mainTable m INNER JOIN #tempTable t ON m BETWEEN t.StartDate AND t.EndDate
(3) Now it should be as simple as SELECT and GROUPING correctly:
SELECT AVG(mA) FROM mainTable m INNER JOIN
Edit: if you want to see intervals with those that have no records (zero average), you will have to twist the query, use LEFT JOIN and COALESCE on mA (see below). If you don't need such interlates, OCary's solution is better / cleaner.
SELECT AVG(COALESCE(mA, 0)) FROM
Phil sandler
source share