Compare Answers To Common Question Vs. Another User

2

Please login or register to vote for this query.

(click on this box to dismiss)

And updated query to the query "Jon Skeet comparison" that allows for comparison against any user.

Lifehacks Meta

Q&A about the site for people looking to bypass life's everyday problems with simple tricks

declare @UserId int = ##UserId##;
declare @OpponentUserId int = ##OpponentUserId##;

with fights as (
  select myAnswer.ParentId as Question,
   myAnswer.Score as MyScore,
   opponentAnswer.Score as OpponentScore
  from Posts as myAnswer
  inner join Posts as opponentAnswer
   on opponentAnswer.OwnerUserId = @OpponentUserId and myAnswer.ParentId = opponentAnswer.ParentId
  where myAnswer.ownerUserId = @UserId and myAnswer.postTypeId = 2
)

select
  case
   when myScore > OpponentScore then 'You win'
   when myScore < OpponentScore then 'You lose'
   else 'Tie'
  end as 'Winner',
  Question as [Post Link],
  myScore as 'My score',
  OpponentScore as "Opponent's score"
from fights;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results