Pareto principle visualization on the estimated daily views of questions

1

Please login or register to vote for this query.

(click on this box to dismiss)

It follows quite well.

History of Science and Math

Q&A for people interested in the history and origins of science and mathematics

DECLARE @now DATETIME = (SELECT MAX(CreationDate) FROM Posts);

WITH Raw AS (
  SELECT
    Id,
    86400.0 * ViewCount / DATEDIFF(s, CreationDate, @now) AS ViewsPerDay
  FROM Posts
  WHERE
    PostTypeId = 1
    AND
    CreationDate < DATEADD(d, -7, @now)
),
Raw2 AS (
  SELECT
    Id,
    ViewsPerDay,
    RANK() OVER (ORDER BY ViewsPerDay DESC, Id) AS Rank,
    SUM(ViewsPerDay) OVER (ORDER BY ViewsPerDay DESC, Id) AS CSum
  FROM Raw
)
SELECT
  100.0 * (Rank - 1) / (SELECT COUNT(*) FROM Raw)
    AS QuestionPercentage,
  CASE
    WHEN ##ShowViewsPerDayPercentage:int?1## <> 0
    THEN 100.0 * Csum / (SELECT SUM(ViewsPerDay) FROM Raw)
  END AS ViewsPerDayPercentage,
  CASE
    WHEN ##ShowAbsoluteViewsPerDay:int?0## <> 0
    THEN ViewsPerDay
  END AS ViewsPerDay
FROM Raw2
WHERE Rank % ((SELECT COUNT(*) FROM Raw) / ##Points:int?100##) = 0

ORDER BY QuestionPercentage;

Enter Parameters

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