Q&A for professional and enthusiast programmers
select sum(case when v.VoteTypeId = 1 then 15 when v.VoteTypeId = 2 then 10 when v.VoteTypeId = 3 then -2 else 0 end) as 'Reputation' from Posts q inner join Posts a on a.ParentId = q.Id inner join Votes v on v.PostId = a.Id where a.CommunityOwnedDate is null and a.OwnerUserId = ##UserId## and a.postTypeId = 2 and not (q.ClosedDate is null)