View count statistics by age group (grouped by month)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Philosophy Meta

Q&A about the site for those interested in the study of the fundamental nature of knowledge, reality, and existence

SELECT DISTINCT(DATEDIFF(MONTH, CreationDate, GETDATE())) AS 'Age in months',
  PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY ViewCount)
    OVER (PARTITION BY DATEDIFF(MONTH, CreationDate, GETDATE())) AS '25%',
  PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ViewCount)
    OVER (PARTITION BY DATEDIFF(MONTH, CreationDate, GETDATE())) AS '50%',
  PERCENTILE_CONT(0.85) WITHIN GROUP (ORDER BY ViewCount)
    OVER (PARTITION BY DATEDIFF(MONTH, CreationDate, GETDATE())) AS '75%',
  ROUND(STDEV(ViewCount)
    OVER (PARTITION BY DATEDIFF(MONTH, CreationDate, GETDATE())), 2) AS 'StDev'
  FROM Posts
  WHERE PostTypeId = 1 -- Questions
  ORDER BY 1 DESC

Enter Parameters

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