WITH RecentPosts AS ( SELECT TOP 3000 * FROM Posts WHERE...

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 @maxdate DATETIME = (SELECT MAX(LastActivityDate) FROM Posts);

WITH RecentPosts AS (
  SELECT TOP 3000 * FROM Posts WHERE PostTypeId = 1 
  ORDER BY LastActivityDate DESC
),
RecentPostsAddedColumns AS (
  SELECT *,
  AnswerScore = (SELECT SUM(Score) FROM Posts a WHERE a.ParentId = q.Id),
  TagWeight = (CASE WHEN Tags LIKE '%<jquery>%' OR Tags LIKE '%<sql>%' THEN 2 ELSE 0 END)
  FROM RecentPosts q
),
WeightedPosts AS (
  SELECT *,
  Weight = TagWeight * 1000
  FROM RecentPostsAddedColumns
)
SELECT TOP 90 * FROM WeightedPosts
ORDER BY Weight DESC

Enter Parameters

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