DECLARE @UserId int = ##UserId## SELECT SUM(AllVotes.Vot...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy

Q&A for science fiction and fantasy enthusiasts

-- Enter Query Title
-- Enter Query Description
DECLARE @UserId int = ##UserId##

SELECT SUM(AllVotes.Votes) FROM
(
SELECT 
    1 * 10 as Votes,
    Votes.CreationDate AS CreationDate
 
FROM Posts 
    INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId = 2
WHERE 
    Posts.OwnerUserId = @UserId
    AND Posts.CommunityOwnedDate IS NULL

UNION 

SELECT
    1 * -10 as Votes,
    Votes.CreationDate AS CreationDate
 
FROM Posts
    INNER JOIN Votes ON Votes.PostId = Posts.Id and VoteTypeId = 3
WHERE
    Posts.OwnerUserId = @UserId
    AND Posts.CommunityOwnedDate IS NULL
) as AllVotes
GROUP BY AllVotes.CreationDate

Enter Parameters

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