Reputation for old questions/answers - aggregate by day


Please login or register to vote for this query.

(click on this box to dismiss)

See This is the aggregate view, aggregated by vote date.


Q&A for community managers, administrators, and moderators

-- Reputation for old questions/answers
-- See
-- This is the base query, which does a similar listing like the one on the user page, but only for older questions and answers. I'll add an aggregate one, too.

with oldVotes as (
select p.PostTypeID as postType,
 v.VoteTypeID as voteType,
 v.ID as voteID,
 p.ID as postID,
 p.CreationDate as pDate,
 v.CreationDate as vDate,
 case p.postTypeID
 when 1 then
  -- question
    case v.voteTypeID
      when 2 then 5  -- upvote
      when 3 then -2 -- downvote
      else 0
 when 2 then
  -- answer
    case v.voteTypeID
      when  1 then 15 -- accepted
      when  2 then 10 -- upvote
      when  3 then -2 -- downvote
      else  0
 end as rep,
 Datediff(day, p.CreationDate, v.CreationDate) as ddiff
from votes as v
 join posts as p
 on v.PostId = p.Id
where p.OwnerUserId = '##userId##'
  and v.votetypeid in (1, 2, 3)
  and Datediff(day, p.CreationDate, v.CreationDate) >  ##minimalDistance##
  count(o.voteID) as vCount,
  sum(o.rep) as rep,
--  vdate,
  convert(varchar(10), o.vdate, 120) as fDate
 from oldVotes o
group by vDate
order by o.vDate

Enter Parameters

Switch to meta site
loading Hold tight while we fetch your results