Usuários por mês

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow em Português

Perguntas e respostas para programadores profissionais e entusiastas

SELECT 
CONVERT(DATETIME, CONCAT(YEAR(CreationDate), '-', MONTH(CreationDate), '-01'), 20) AS Mes,
COUNT(*) AS 'Usuários novos no mês',
(
   SELECT COUNT(*) FROM Users u 
   WHERE CONCAT(YEAR(u.CreationDate), '-', MONTH(u.CreationDate)) <=
         CONCAT(YEAR(Users.CreationDate), '-', MONTH(Users.CreationDate))
) AS 'Usuários totais'
FROM Users

GROUP BY YEAR(CreationDate), MONTH(CreationDate)
ORDER BY YEAR(CreationDate), MONTH(CreationDate)

Enter Parameters

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