Vote Count Summary (per user) - selected user(s)

Vote Count Summary (per user) - selected user(s)

-- [params]
-- user_list :users

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
WHERE tvv.user_id IN (:users)
GROUP BY tvv.user_id
ORDER BY tvv.user_id ASC