Total count of up- and downvotes in the system from the Users and the Votes table

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

SELECT
  'Users Table' AS Source,
  SUM(UpVotes) AS Ups,
  SUM(DownVotes) AS Downs
FROM Users

UNION

SELECT
  'Votes Table' AS Source,
  COUNT(CASE WHEN VoteTypeId=2 THEN 1 ELSE NULL END) Ups,
  COUNT(CASE WHEN VoteTypeId=3 THEN 1 ELSE NULL END) Downs
FROM Votes

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results