I have some data generated during time. I used the query below to count the number of "interactions" which happened every hour.
SELECT COUNT(*) as Quantity, FORMAT(cast(InteractionDate as datetime2), 'yyyy-MM-dd HH') as Datum
FROM Interaction as in
INNER JOIN Mission as mi
on in.MissionID=mi.MissionID
WHERE InteractionDate between '2015-01-13 12' AND '2015-01-22 12'
GROUP BY FORMAT(cast(InteractionDate as datetime2), 'yyyy-MM-dd HH')
ORDER BY Datum
The query above gives me this:
116 | 2015-01-15 00
37 | 2015-01-15 01
17 | 2015-01-15 02
Now i want to get the aggregated number of interactions on every nth hour. Let's say I want every 3rd hour, for the data provided I would get:
170 | 2015-01-15 02
How can I do that?