Go Questions and Answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

DECLARE @PostCreatedAfter smalldatetime
SET @PostCreatedAfter = DATEADD(MONTH, -4, GETDATE()) 

CREATE TABLE #TagsFilter (
              Id int              
              , TagName nvarchar(35) COLLATE SQL_Latin1_General_CP1_CS_AS
              , [Count] int);
INSERT INTO #TagsFilter 
       SELECT Id, TagName, [Count] FROM Tags
       WHERE TagName in ('go', 'c#', 'java', 'swift', 'php', 'dart', 'flutter')


-- Select TagId, MonthsAgo, AnswerCount, Count(QuestionId) as QuestionIdCount
--   , Sum(AnswerCount) as AnswerCountSum, Sum(AnswerScore) as AnswerScoreSum
--   FROM (
        Select 
           pt.TagId
           , p.Id as QuestionId
           , p.ViewCount
           , p.Score as QuestionScore
           , p.AnswerCount
           ,CASE 
               WHEN p.AnswerCount = 0 AND pt.TagId = 15627  THEN 'Go unanswered'
               WHEN p.AnswerCount > 0 AND pt.TagId = 15627  THEN 'Go answered'
               END as TagAnswered 
           ,CASE WHEN p.AnswerCount > 0 THEN p.AnswerCount END as Answered
           -- , p2.Id as AnswerId
           -- , p2.Score as AnswerScore
           -- , p2.ParentId   
           , (DATEDIFF(Month,p.CreationDate, @PostCreatedAfter)*1) as MonthsAgo  
           -- , Count(p.Id) as QuestionCount
           -- , Sum(p.AnswerCount) as AnswerCount
           -- , Sum(p.Score) as SumQuestionScore
           -- , Sum(p2.Score) as SumAnswerScore
          FROM  Posts p
          Left JOIN PostTags pt on pt.PostId = p.Id
          LEFT JOIN Posts p2 on p.Id = p2.ParentId
          WHERE pt.TagId =  15627 -- Go          
          AND  p.CreationDate >= @PostCreatedAfter
          -- AND p.AnswerCount = 0
          -- Group By pt.TagId ,p.AnswerCount
          --  , (DATEDIFF(Month,p.CreationDate, @PostCreatedAfter)*1)          
          -- ORDER BY MonthsAgo, QuestionId
--     ) as sq
--    GROUP BY TagId, MonthsAgo, AnswerCount
--    Order By TagId, MonthsAgo, AnswerCount

Enter Parameters

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