active users by year-month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Physics

Q&A for active researchers, academics and students of physics

SELECT period, Count(UserId) usercount
       
FROM   (
        SELECT UserId, 
        CONVERT(CHAR(7), CreationDate, 20) as period 
        FROM   PostHistory
        UNION 
        SELECT OwnerUserId, 
        CONVERT(CHAR(7), CreationDate, 20) as period 
        FROM   Posts 
        ) t
GROUP  BY period
HAVING period <> CONVERT(CHAR(7), DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0), 20)

ORDER BY
        period

Enter Parameters

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