DECLARE @MyUserID INT = ##UserID:int## DECLARE @OtherUser...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @MyUserID INT = ##UserID:int##
DECLARE @OtherUserName nvarchar(600) = ##PostText:string##

SELECT
    Answer.Id AS [Post Link],
    Answer.Score AS [Score],
    [Answer State] =
    CASE
        WHEN Answer.Id = Question.AcceptedAnswerId THEN
            'Accepted'
        ELSE 
            '---'
    END,
    Answer.CreationDate AS [Creation Date]
FROM
    Posts Question
LEFT JOIN Users ON Question.OwnerUserId = Users.Id
LEFT JOIN Posts Answer ON Question.ID = Answer.ParentId
WHERE
    UPPER(Users.DisplayName) LIKE '%' + @OtherUserName + '%' AND
    Answer.PostTypeId = 2 AND
    Answer.OwnerUserId = @MyUserID    
ORDER BY
    Question.CreationDate
ASC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results