Q&A for those interested in the geology, meteorology, oceanography, and environmental sciences
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##) ) SELECT VoteTypeId, Answer, count(*) as VoteTypeIdCount FROM a GROUP BY VoteTypeId, Answer