Basic query to track questions with an answer inside

1

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 @QuestionsSince datetime;
DECLARE @QuestionsUntil datetime;

SET  @QuestionsSince = DATEADD(week, -1 * ##WeeksOld:int?1##, GETUTCDATE());
SET  @QuestionsUntil = GETUTCDATE();

SELECT q.Id AS [Post Link]
FROM Posts AS q
WHERE q.PostTypeId = 1
	AND q.LastEditDate BETWEEN @QuestionsSince AND @QuestionsUntil
	AND EXISTS(
		SELECT NULL
		FROM PostHistory AS h
		INNER JOIN Comments AS c ON c.CreationDate > h.CreationDate
		WHERE h.PostId = q.Id AND h.PostHistoryTypeId IN (4, 5) AND h.UserId = q.OwnerUserId
 			AND c.PostId = q.Id AND c.UserId = ##UserId## AND c.Text LIKE N'%https://stackoverflow.com/help/self-answer%')
	AND NOT EXISTS(
		SELECT NULL
		FROM Posts AS a
		WHERE a.ParentId = q.Id AND a.OwnerUserId IN (##UserId##, q.OwnerUserId));

Enter Parameters

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