Total number of registered users over time

0

Please login or register to vote for this query.

(click on this box to dismiss)

Shows the total number of registered users for every month since site inception.

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

-- Total number of registered users over time
-- Shows the total number of registered users for every month since site inception.

WITH c AS
(
    SELECT
        DATEPART(year, CreationDate) AS Year,
        DATEPART(month, CreationDate) AS Month
        FROM Users
),
d AS
(
    SELECT
        Year,
        Month,
        COUNT(*) OVER(PARTITION BY Year, Month) AS Count
        FROM c
),
e AS
(
    SELECT Year, Month, Count
        FROM d
        GROUP BY Year, Month, Count
),
f AS
(
    SELECT
        ROW_NUMBER() OVER(ORDER BY Year, Month) AS RowId,
        Year, Month, Count
        FROM e
)
SELECT
    Year,
    Month,
    (SELECT SUM(Count) FROM f WHERE f.RowId <= q.RowId) AS TotalCount
    FROM f q
    WHERE Year = 2011
    ORDER BY Year, Month

Enter Parameters

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