/* Best of Code Review 2016 - Best Newcomer (answer) cate...

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

/*
Best of Code Review 2016 - Best Newcomer (answer) category
http://meta.codereview.stackexchange.com/questions/7128/best-of-code-review-2016-best-newcomer-answer-category
*/
DECLARE @TargetYear INT = 2016;
DECLARE @Question INT = 1;
WITH Questions2016 AS (
  SELECT p.Id AS [PostId]
  FROM Posts AS p
  WHERE p.PostTypeId = @Question
  AND DATEPART(YEAR, p.CreationDate) = @TargetYear
  AND p.ClosedDate IS NULL
)
SELECT
  p.Title,
  LEN(p.Title) AS [Title Length],
  p.ViewCount,
  p.Score,
  p.Tags,
  p.OwnerUserId AS [User Link],
  u.Reputation,
  p.CreationDate,
  q.PostId AS [Post Link]
FROM 
  Questions2016 AS q
  JOIN Posts AS p
    ON q.PostId = p.Id
  JOIN Users AS u
    ON p.OwnerUserId = u.Id
ORDER BY 
  p.ViewCount DESC,
  p.Score DESC,
  p.Title ASC,
  p.CreationDate ASC

Enter Parameters

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