Does anyone have a query for Stack Overflow's database to get the total amount of upvotes (on Stack Overflow) month by month? Just thinking about it makes my head hurt. (SEDE)
-
1Related (cross-site): SEDE query for questions asked per month (help needed)– Peter MortensenJan 12, 2017 at 16:48
-
1:P my own question related to another one of my questions– user5957083Jan 12, 2017 at 16:50
-
@ChristopherPeart: Yes, because you basically cross-posted it.– lxgJan 15, 2017 at 12:37
-
@PeterMortensen - I don't see any particular relationship between the questions except they are both about querying SEDE and posted by the same user. The questions asked are not the same. (What do the PostTypeID mean? vs How to get monthly upvotes and downvotes)– Martin SmithJan 15, 2017 at 12:44
-
@lxg Where is the cross post?– Martin SmithJan 15, 2017 at 12:48
-
Ok, maybe not exactly cross-posted, but they both refer to things that can be researched by oneself through SEDE. On SO, I would consider such a question being “too broad”. If one is struggling building the SEDE query, they should point out what they’ve tried so far and where excactly they got stuck.– lxgJan 15, 2017 at 13:01
Add a comment
|
1 Answer
You mean something like this? (thanks for the improvement, @CodyGray)
It's about 1.4 million upvotes each month; the number of downvotes is about a factor 7 lower.
For reference, here is the complete query:
SELECT DATEADD(MONTH, M, 0) AS Month,
( 1 - GROUPING(M) ) * SUM(IIF(VoteTypeId = 2, 1, 0)) AS UpVotes,
( 1 - GROUPING(M) ) * SUM(IIF(VoteTypeId = 3, 1, 0)) AS DownVotes
FROM Votes
CROSS APPLY (VALUES (DATEDIFF(MONTH, 0, CreationDate))) V(M)
WHERE VoteTypeId IN ( 2, 3 )
AND CreationDate >= '2016-01-01'
AND CreationDate < '2017-01-01'
GROUP BY GROUPING SETS ( ( ), ( M ) )
Note that SEDE is updated once a week, on Sunday morning.
-
3
-
13
-
2Thanks! Exactly what I wanted (and more). I was worried about getting flagged!– user5957083Jan 12, 2017 at 2:48
-
The tracks by CreationDate. Shouldn't that mean that - and it appears to me to be the case - the older a question the more votes? If today I up vote something created last March, correct? I imagine it's not a major trending curve, but that would also explain why December's count is the lowest.– user7014451Jan 12, 2017 at 15:22
-
CreationDate is the creation date of the vote, not the post. December is the lowest because it's holiday season. Jan 12, 2017 at 15:22
-
6@Glorfindel There are lies, damn lies, and graphs not starting at zero… Jan 12, 2017 at 15:27
-
I know. The old one was better in that regard, but it still didn't start at zero. Jan 12, 2017 at 15:28
-
2
-
1@Glorfindel The accepted answer for that topic says: “Show zero on the y axis if comparisons with zero are central to the problem, or even of some interest”, — that is totally the case for graphs like above, i. e. “popularity” graphs, as we naturally compare popularity rates with each other and against “no popularity at al” (which is zero). In fact, 1325000 is 88 % of 1500000, yet the graph above depicts it more like 30 %. Jan 12, 2017 at 15:37
-
1I don't really agree that comparing against 0 is vital; the OP just asks for a number. Furthermore, I can't change the graph, it comes directly from SEDE. You can propose a [feature-request] to have this changed. Jan 12, 2017 at 15:40
-
-
1@AntonSamsonov there is a pleasant mix of all three shown at my quarterly company-wide meetings. It's a recurring joke that gives us all a little chuckle. Jan 12, 2017 at 21:29
-
My upvote to downvote ratio is probably the opposite of the site average. I'm amazed at those stats considering the quality of questions on SO.– TurnipJan 13, 2017 at 11:05
-
4Upvotes on questions are free (no reputation loss), and a user can cast upvotes at a much lower reputation threshold than they can downvotes. The stats are quite believable, though still backwards from the way it should be. @turnip– Cody Gray ModJan 15, 2017 at 12:16
-