Total users added, by month

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

declare @end as DateTime = (select dateadd(month, datediff(month, 0, max(CreationDate)), 0) from Users);

select dateadd(month, datediff(month, 0, u.CreationDate), 0) as 'month', 
  count(*) as '# Users Added',
  count(iif(u.Reputation >= 50, 1, null)) as '# Users Added (current rep >= 50)'--,
  --(select count(p.Id) from Posts p where p.PostTypeId = 2 and p.OwnerUserId = u.Id GROUP BY u.Id) >= 2 as '# Users Added (answers posted >=2)'

from Users u
-- left join posts p on p.PostTypeId = 2 AND p.OwnerUserId = u.Id

where dateadd(month, datediff(month, 0, u.CreationDate), 0) < @end
    --and u.Reputation >= 50

group by dateadd(month, datediff(month, 0, u.CreationDate), 0)
order by dateadd(month, datediff(month, 0, u.CreationDate), 0)

Enter Parameters

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