Q&A for anime and manga fans
WITH accountsByDate AS ( SELECT CAST(u.LastAccessDate AS DATE) as [Date], COUNT(*) as numUsers FROM Users u GROUP BY CAST(u.LastAccessDate AS DATE) ) SELECT a.[Date], AVG(a.numUsers) OVER ( ORDER BY a.[Date] ROWS BETWEEN ##MovingAvg:int?20## PRECEDING AND CURRENT ROW ) FROM accountsByDate a