DECLARE @UserId int = ##UserId## SELECT CASE WHEN PostT...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

-- Enter Query Title
-- Enter Query Description

DECLARE @UserId int = ##UserId##

SELECT
    CASE WHEN PostTypeId = 1 THEN 'Question' ELSE 'Answer' END As [Post Type],
    Count(*) AS Amount,
    vt.Name
     /* SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes,
    SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes
     */
--  ,  (CAST(SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS float) / CAST(SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS float)) AS UpVoteDownVoteRatio
FROM
    Votes v JOIN Posts p ON v.PostId=p.Id
    INNER JOIN VoteTypes vt ON v.VoteTypeId = vt.Id
WHERE 
   -- p.OwnerUserId=@UserId
   v.UserId=@UserId
GROUP BY
    PostTypeId, vt.Name
ORDER BY
    PostTypeId, vt.Name

Enter Parameters

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