Active users

0

Please login or register to vote for this query.

(click on this box to dismiss)

Internet of Things

Q&A for builders and users of networked sensors and control devices in the contexts of smart homes, industry automation, or environmental sensors

SELECT Month = DATEADD(MONTH, DATEDIFF(MONTH, 0, Posts.CreationDate), 0),
       'Active users' = COUNT(distinct OwnerUserId)
FROM Posts
INNER JOIN Users
ON Posts.OwnerUserId = Users.Id
GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, Posts.CreationDate), 0)
ORDER BY Month

/* 
Normalised:

NOTE: 'Active users nonnormalised' = COUNT(distinct OwnerUserId) 

SELECT Month = DATEADD(MONTH, DATEDIFF(MONTH, 0, Posts.CreationDate), 0),
       'Active users' = CAST(COUNT(distinct OwnerUserId) AS FLOAT) /
       (SELECT MAX([Active users nonnormalised])
        FROM (
              SELECT Month = DATEADD(MONTH, DATEDIFF(MONTH, 0, Posts.CreationDate), 0),
                     'Active users nonnormalised' = COUNT(distinct OwnerUserId)
              FROM Posts
              INNER JOIN Users
              ON Posts.OwnerUserId = Users.Id
              GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, Posts.CreationDate), 0)
              ) AS Active_users_nonnormalised)
FROM Posts
INNER JOIN Users
ON Posts.OwnerUserId = Users.Id
GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, Posts.CreationDate), 0)
ORDER BY Month
*/

Enter Parameters

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