Q&A for professional and enthusiast programmers
-- This query displays the questions where the two users meet.
-- It accepts two paramaters:
-- @AskerID => the who raised the question
-- @AnswererID => the one who answered
-- It also display whether the answer has been accepted or not.
-- All users are ALLOWED to fork this query for improvements.
DECLARE @AskerID int = ##AskerId##
DECLARE @AnswererID int = ##AnswererID##
SELECT a.CreationDate as [DateAsked],
a.ID AS [Post Link],
c.Body AS [Answer],
CASE WHEN a.AcceptedAnswerID = c.ID THEN 'Accepted' ELSE '' END [Status]
FROM Posts a
SELECT aa.ParentId, aa.Body, aa.OwnerUserId, aa.ID
FROM Posts aa
INNER JOIN PostTypes bb
ON aa.PostTypeId = bb.ID AND bb.ID = 2
WHERE aa.OwnerUserId = @AnswererID
) c ON a.ID = c.ParentId
WHERE a.OwnerUserId = @AskerID AND
a.PostTypeId = 1
ORDER BY a.CreationDate ASC