histogram of number of downvotes for a given user, date-limited

1

Please login or register to vote for this query.

(click on this box to dismiss)

Returns the distribution of scores on answers by a user during a given date interval. Not quite a histogram because the zeros don't get drawn.

Tezos

Q&A for users, experts, and developers of the Tezos blockchain project

declare @EndDate datetime = (select case
  -- If we request 'today', actually use the date
  -- of the most recent transfer to this database,
  -- which may be as much as a week in the past.
  when lower(##EndDate:string?today##) = 'today' then max(CreationDate)
  -- Otherwise, specify the most recent date to include.
  else ##EndDate##
  end
  from Posts
);
  
declare @StartDate datetime = dateadd(day, -1*##DaysBack?30##, @EndDate);

SELECT
vote_info.downvotes AS Downvotes,
COUNT(answers.Id) AS 'Answers with Downvotes'
FROM Posts Questions 
INNER JOIN Posts answers ON answers.ParentId = Questions.Id
INNER JOIN (
  SELECT downvotes=SUM(case when VoteTypeId = 3 then 1 else 0 end), PostId
  FROM Votes
  GROUP BY PostId) vote_info ON vote_info.PostId = answers.Id
WHERE answers.OwnerUserId = ##userId##
  AND questions.CommunityOwnedDate IS NULL
  AND answers.CreationDate between @StartDate and @EndDate
  --Exclude questions that were HNQ before the answer was posted
GROUP BY vote_info.downvotes
ORDER BY vote_info.downvotes;

Enter Parameters

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