Election Votes per Hour

0

Please login or register to vote for this query.

(click on this box to dismiss)

Android Enthusiasts

Q&A for enthusiasts and power users of the Android operating system

WITH
  Votes AS (
    SELECT
      DATEPART(HOUR, b.Date) AS VoteHour,
      CAST(b.Date AS DATE) AS VoteDate,
      DATEPART(YEAR, b.Date) AS ElectionYear
    FROM Badges b
    WHERE b.Name = 'Constituent'
  ),
  VotesPerHour AS (
    SELECT
      DATETIMEFROMPARTS(YEAR(VoteDate), MONTH(VoteDate), DAY(VoteDate), VoteHour, 0, 0, 0) AS VoteDateHour,
      ElectionYear
    FROM Votes
  )
SELECT
  VoteDateHour,
  COUNT(*) AS BadgeCount
FROM VotesPerHour
WHERE ElectionYear = ##electionyear##
GROUP BY
  VoteDateHour
ORDER BY
  VoteDateHour

Enter Parameters

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