DECLARE @From DATETIME = convert(DATETIME, '##StartDate?2...

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 @From DATETIME = convert(DATETIME, '##StartDate?2015-10-01##')
DECLARE @To DATETIME = dateadd(mm, 3, @From)

SELECT TOP ##Count:int?50## Q.Id AS [Post Link], 
  Q.CreationDate AS Created, Q.ViewCount AS Views, 
  Q.Score AS [Question Score], max(A.Score) AS [Max Answer Score], 
  Q.FavoriteCount AS Favorited
FROM
  Posts Q
  LEFT JOIN Posts A ON A.ParentId = Q.Id
WHERE
  Q.ClosedDate IS NULL AND
  Q.PostTypeId = 1 AND
  Q.CreationDate BETWEEN @From AND @To
GROUP BY Q.Id, Q.CreationDate, Q.ViewCount, Q.Score, Q.FavoriteCount
ORDER BY Q.ViewCount DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results