WITH a AS ( SELECT v.PostId, v.VoteTypeId, t.Name, v.Crea...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Gardening and Landscaping

Q&A for gardeners and landscapers

WITH a AS (
SELECT v.PostId, v.VoteTypeId, t.Name, v.CreationDate, v.BountyAmount,
CASE  
    WHEN v.VoteTypeId IN (1) THEN 15
    WHEN v.VoteTypeId IN (2) THEN 10
    WHEN v.VoteTypeId IN (3) THEN -2
    Else 0
END AS Answer
FROM Votes v
JOIN VoteTypes t ON v.VoteTypeId = t.Id
WHERE PostId IN (
SELECT Id
FROM Posts
WHERE OwnerUserId = ##UserId##)
AND v.CreationDate > DATEADD(year, -1, GetDate())
)
SELECT SUM(c.VoteTypeIdCountProduct) FROM (
SELECT VoteTypeId, Answer, count(*) AS VoteTypeIdCount, Answer * count(*) AS VoteTypeIdCountProduct FROM a
GROUP BY VoteTypeId, Answer
)c;


WITH e AS (
SELECT 
CASE  
    WHEN ApprovalDate > DATEADD(year, -1, GetDate()) THEN 2
    Else 0
END AS Answer
FROM SuggestedEdits
WHERE OwnerUserId = ##UserId##
)
SELECT SUM(Answer)
FROM e
WHERE 1=1

Enter Parameters

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