Using the Stack Exchange Data Explorer I’m trying to figure out who the top ten answerers on Stack Overflow are. This is my query:
SELECT TOP 10 COUNT (PostTypeId) postcount, OwnerUserId
FROM Posts
WHERE PostTypeId = '2' AND OwnerUserId IS NOT NULL
GROUP BY OwnerUserId
ORDER BY postcount DESC
And, these are my results:
postcount OwnerUserId
--------- -----------
23628 22656
17505 29407
12978 157882
10863 34397
10598 23354
10560 17034
9341 20862
8600 115145
7394 57695
7073 1583
The problem is: User 22656 is Jon Skeet, and his profile says he has 23,702 answers.
I checked the others: Darin Dimitrov is User 29407. His profile indicates he has 17,525 answers, not merely 17,505. The others are all similarly skewed.
Why am I getting wrong totals in postcount? How can I fix this?
You are seeing more answers on Jon’s profile because you have a diamond and are seeing his deleted answers.
I see “23,702 Answers” which is closer to the value reported by your query.
The rest of the discrepancy is down to the fact that the data explorer isn’t updated on a minute by minute basis so will always report lower totals (assuming people are adding more content of course).