DECLARE @Example TABLE (SiteName nvarchar(32), UpVotes in...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Motor Vehicle Maintenance and Repair

Q&A for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

DECLARE @Example TABLE (SiteName nvarchar(32), UpVotes int, DownVotes int)

INSERT INTO @Example SELECT DB_NAME(),
  COUNT(CASE WHEN VoteTypeId = 2 THEN 1 ELSE NULL END),
  COUNT(CASE WHEN VoteTypeId = 3 THEN 1 ELSE NULL END)
  FROM Votes WHERE VoteTypeId IN(2, 3);

USE [StackExchange.Worldbuilding];
INSERT INTO @Example SELECT DB_NAME(),
  COUNT(CASE WHEN VoteTypeId = 2 THEN 1 ELSE NULL END),
  COUNT(CASE WHEN VoteTypeId = 3 THEN 1 ELSE NULL END)
  FROM Votes WHERE VoteTypeId IN(2, 3);

USE [StackExchange.DevOps];
INSERT INTO @Example SELECT DB_NAME(),
  COUNT(CASE WHEN VoteTypeId = 2 THEN 1 ELSE NULL END),
  COUNT(CASE WHEN VoteTypeId = 3 THEN 1 ELSE NULL END)
  FROM Votes WHERE VoteTypeId IN(2, 3);

SELECT * FROM @Example

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results