SELECT MIN(QuestionDate) as period, SUM(AnsweredViews) as...

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

SELECT
      MIN(QuestionDate) as period,
      SUM(AnsweredViews) as AnsweredViews,
      SUM(UnansweredViews) as UnansweredViews
FROM (

  SELECT
        Questions.Id as 'Question',
        Questions.CreationDate as 'QuestionDate',
        Questions.ViewCount as 'ViewCount',
        Answers.CreationDate as 'AnswerDate',
        Answers.Id as 'AnswerId',
        Answers.Score as 'AnswerScore',
        ROW_NUMBER() OVER (PARTITION BY Questions.Id ORDER BY Answers.Score DESC) as 'AnswerNum',
        CONCAT('https://stackoverflow.com/questions/', Questions.Id) as 'Link',
        Questions.Tags as 'Tags',
        (CASE
          WHEN Answers.Id IS NULL THEN 0
          ELSE Questions.ViewCount
          END) as AnsweredViews,
          (CASE
          WHEN Answers.Id IS NULL THEN Questions.ViewCount
          ELSE 0
          END) as UnansweredViews
      FROM
        Posts as Questions
        LEFT OUTER JOIN Posts as Answers ON (Answers.ParentId = Questions.Id)
      WHERE Questions.Tags LIKE '%google-cloud-dataflow%'
  ) AS base
  LEFT OUTER JOIN Votes as Votes ON AnswerId = Votes.PostId
  
    GROUP BY DATEPART(month, QuestionDate), DATEPART(year, QuestionDate)
          ORDER BY period

Enter Parameters

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