View count statistics by age group

0

Please login or register to vote for this query.

(click on this box to dismiss)

Mythology

Q&A for enthusiasts and scholars of mythology and folklore

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

Enter Parameters

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