Inactive User Spread

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

WITH all_users AS (
    SELECT count(*) AS general
    FROM Users
    WHERE Reputation = 1
), users_last_thirty_days AS (
    SELECT count(*) AS thirty
    FROM Users
    WHERE Reputation = 1 AND LastAccessDate < DATEADD(DAY, -30, GETDATE())
), users_last_ninety_days AS (
    SELECT count(*) AS ninety
    FROM Users
    WHERE Reputation = 1 AND LastAccessDate < DATEADD(DAY, -90, GETDATE())
), users_last_hundred_eighty_days AS (
    SELECT count(*) AS hundred_eighty
    FROM Users
    WHERE Reputation = 1 AND LastAccessDate < DATEADD(DAY, -180, GETDATE())
)

SELECT
  general,
  (general - thirty)        AS general_delta,
  thirty,
  (thirty - ninety)         AS thirty_delta,
  ninety,
  (ninety - hundred_eighty) AS ninety_delta,
  hundred_eighty
FROM all_users, users_last_thirty_days, users_last_ninety_days, users_last_hundred_eighty_days;

Enter Parameters

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