Questions with best answer created within 3 month range

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

Q&A about the site for members of the workforce navigating the professional setting

-- Questions with most max Answer Score
-- The top 20 questions with best Answer score within 3 month range
DECLARE @From_Date DATETIME = convert(DATETIME, '##StartDate?2013/01/01##')
DECLARE @To_Date DATETIME = dateadd(mm, 3, @From_Date)

PRINT 'from ' + format(@From_Date, 'D') + ' to ' + format(@To_Date, 'D')

SELECT TOP 40 Posts.id AS [Post Link],
	Posts.CreationDate,
	Posts.Score AS [Question Score],
	max(Answer.Score) AS [max Answer Score],
	Posts.ViewCount,
	Posts.FavoriteCount
FROM Posts
INNER JOIN users
	ON Posts.OwnerUserId = users.id
LEFT JOIN Posts AS Answer
	ON Answer.parentid = Posts.id
		AND Answer.posttypeid = 2
WHERE Posts.ClosedDate IS NULL
	AND Posts.posttypeid = 1
    AND Posts.Tags like '%python%'
	AND Posts.CreationDate BETWEEN @From_Date
		AND @To_Date
GROUP BY Posts.Id,
	Posts.CreationDate,
	Posts.Score,
	Posts.ViewCount,
	Posts.FavoriteCount
ORDER BY max(Answer.Score)  DESC

Enter Parameters

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