Q&A about the site for administrators and users of the CiviCRM Constituent Relationship Management software
-- Up vs Down votes by day of week of Question or Answer SELECT CASE WHEN PostTypeId = 1 THEN 'Question' ELSE 'Answer' END As [Post Type], DATENAME(WEEKDAY, p.CreationDate) AS Day, Count(*) AS Amount, SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes, (CAST(SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS float) / CAST(SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS float)) AS UpVoteDownVoteRatio FROM Votes v JOIN Posts p ON v.PostId=p.Id GROUP BY PostTypeId, DATEPART(WEEKDAY, p.CreationDate), DATENAME(WEEKDAY, p.CreationDate) ORDER BY PostTypeId, DATEPART(WEEKDAY, p.CreationDate)