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 dvv.user_id,
       SUM(CASE when dvv.archive = FALSE THEN 1 ELSE 0 END) AS "Current Votes Cast",
       SUM(CASE when dvv.archive = TRUE THEN 1 ELSE 0 END) AS "Archived Votes",
       COUNT(dvv.user_id) AS "Total Votes Cast"
FROM discourse_voting_votes dvv
GROUP BY dvv.user_id
ORDER BY dvv.user_id ASC