What questions does Jon Skeet have a higher/lower score on than me?
Q&A for science fiction and fantasy enthusiasts
-- Jon Skeet comparison -- What questions does Jon Skeet have a higher/lower score on than me? declare @UserId int = ##UserId##; with fights as ( select myAnswer.Id as Id, myAnswer.ParentId as Question, myAnswer.Score as MyScore, jonsAnswer.Score as JonsScore from Posts as myAnswer with (nolock) inner join Posts as jonsAnswer with (nolock) on jonsAnswer.OwnerUserId = 22656 and myAnswer.ParentId = jonsAnswer.ParentId -- inner join Posts as Posts on Posts.Id where myAnswer.ownerUserId = @UserId ) select Id, case when myScore > JonsScore then 'You win' when myScore < JonsScore then 'Jon wins' else 'Tie' end as 'Winner', Question as [Post Link], myScore as 'My score', jonsScore as "Jon's score" from fights order by Id desc