I have a newsletter where the total number of monthly SO questions is a data point for technology popularity. Here are JVM languages and their competitors, for example. I also query the total number of monthly SO questions for context. I use the Data Explorer for that. The query is below and goes up to Oct 31, 2023.
I ran the query on Nov 28 last year (Git timestamp) and stored the results. Then I ran the same query unchanged today: November 2022 now has 10% fewer questions, December 2022 and January 2023 19%, February 2023 is off by nearly 8%, and October 2023 is off by almost 5%.
I can see why the number fluctuates a bit. Emphasis on "bit": From January 2009 through October 2022, the average difference between my November 2023 and February 2024 results was 0.05%. Even from March to September 2023, it was just 0.45%.
You can find all the data in this Google sheet, problem area highlighted.
What's wrong with my query to get such huge differences?
DECLARE @StartDate DATE = '2009-01-01';
DECLARE @EndDate DATE = '2023-10-31';
WITH Questions AS (
SELECT
Id,
CreationDate,
1 AS AQuestion
FROM Posts
WHERE
PostTypeId = 1 AND -- 1 for questions
CreationDate >= @StartDate AND
CreationDate <= @EndDate
),
MonthlyCounts AS (
SELECT
DATEADD(month, DATEDIFF(month, 0, CreationDate), 0) AS Month,
SUM(AQuestion) AS Questions
FROM Questions
GROUP BY DATEADD(month, DATEDIFF(month, 0, CreationDate), 0)
)
SELECT
Month,
Questions
FROM MonthlyCounts
ORDER BY Month;