Q&A about the site for gardeners and landscapers
declare @userId int = ##userId##; select p.* from ( select a.Id ,q.Title ,vt.Name from Posts as a join Posts as q on q.Id = a.ParentId left join Votes as v join VoteTypes as vt on vt.Id = v.VoteTypeId on v.PostId = a.Id and v.VoteTypeId in (1,2,3) where a.OwnerUserId = @userId and a.PostTypeId = 2 -- answer ) as q pivot ( count(q.Name) for q.Name in ( AcceptedByOriginator ,UpMod ,DownMod ) ) as p order by p.DownMod desc