The most-viewed unanswered questions for a tag

5

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers

Q&A for Drupal developers and administrators

DECLARE @TagLike NVARCHAR(25) = ##taglike:string##

select DISTINCT top 100  q.Id as [Post Link],  q.ViewCount, q.CreationDate AS QuestionDate,
  Answers = (SELECT COUNT(*) FROM dbo.Posts a WHERE q.Id = a.ParentId AND a.PostTypeId = 2),
  AnswersUpvoted = (SELECT COUNT(*) FROM dbo.Posts a WHERE q.Id = a.ParentId AND a.PostTypeId = 2 AND a.Score > 1)
  from Posts q
    INNER JOIN PostTags ON q.Id = PostTags.PostId
    INNER JOIN Tags ON PostTags.TagId = Tags.id
where (select count(*) from Posts a where a.ParentId = q.Id and a.Score > 0) = 0
and CommunityOwnedDate is null and ClosedDate is null and q.ParentId is null 
and AcceptedAnswerId is null
AND Tags.TagName LIKE '%' + @TagLike + '%'
ORDER BY q.ViewCount DESC

Enter Parameters

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