Vote Count Summary (per user) - all users

Vote Count Summary (per user) - all users

The following query gives the number of current votes, the number of archived votes, and the combined total, per user.

SELECT tvv.user_id,
       SUM(CASE when tvv.archive = FALSE THEN 1 ELSE 0 END) AS "Current Votes Cast",
       SUM(CASE when tvv.archive = TRUE THEN 1 ELSE 0 END) AS "Archived Votes",
       COUNT(tvv.user_id) AS "Total Votes Cast"
FROM topic_voting_votes tvv
GROUP BY tvv.user_id
ORDER BY tvv.user_id ASC