StackOverflowDocumentation
.dbo
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
usp_Q3160
Parameters
Name
Type
Mode
@UserId
int
IN
Definition
CREATE PROC [dbo].[usp_Q3160] @UserId INT AS BEGIN /* Source: http://data.stackexchange.com/stackoverflow/query/3160/jon-skeet-comparison */ with fights as ( select myAnswer.ParentId as Question, myAnswer.Score as MyScore, jonsAnswer.Score as JonsScore from Posts as myAnswer inner join Posts as jonsAnswer on jonsAnswer.OwnerUserId = 22656 and myAnswer.ParentId = jonsAnswer.ParentId where myAnswer.OwnerUserId = @UserId and myAnswer.PostTypeId = 2 ) select 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; END