Probability of a post to get a VoteType 4 by month

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow на русском Meta

Вопросы и ответы о сайте для программистов

WITH PostStat AS (
  SELECT
    DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1) AS Month,
    COUNT(*) AS Count
  FROM Posts
  WHERE
    PostTypeId BETWEEN 1 AND 2
  GROUP BY DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1)
),
VT4Stat AS (
  SELECT
    DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1) AS Month,
    COUNT(*) AS Count
  FROM Votes
  WHERE
    VoteTypeId = 4
  GROUP BY DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1)
)
SELECT
  PostStat.Month,
  100.0 * VT4Stat.Count / PostStat.Count AS Pct
FROM PostStat, VT4Stat
WHERE
  PostStat.Month = VT4Stat.Month
ORDER BY PostStat.Month

Enter Parameters

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