Vote Totals by Day in [Range]

1

Please login or register to vote for this query.

(click on this box to dismiss)

Pulls up/ down/ total votes grouped by day for the given date range, inclusive of both dates.

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

DECLARE @SEDEUpdated AS DATETIME = (SELECT TOP 1 LastAccessDate FROM Users ORDER BY LastAccessDate DESC)

SELECT
  v.CreationDate AS [Date],
  COUNT(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE NULL END) AS [Upvotes],
  COUNT(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE NULL END) AS [Downvotes],
  COUNT(*) AS [Up & Dwn Votes]
FROM Votes v
WHERE v.VoteTypeId IN (2, 3) -- Limit to Up/ Downvotes
  AND v.CreationDate BETWEEN ##StartDate:string## AND ##EndDate:string##
  AND v.CreationDate < DATEFROMPARTS(YEAR(@SEDEUpdated), MONTH(@SEDEUpdated), DAY(@SEDEUpdated)) -- Exclude SEDE update day
GROUP BY v.CreationDate
ORDER BY v.CreationDate

-- StartDate: First Day of Range:
-- EndDate: Last Day of Range:

Enter Parameters

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