Help to build a report: new user accounts per month

Re: Help to build a report: new user accounts per month

by Iñaki C. -
Number of replies: 2

Thank you very much! That's exactly what I was looking for.

In reply to Iñaki C.

Re: Help to build a report: new user accounts per month

by Jason Lane -

Very effective! Is there a way to extend this so just the username is appended into brackets in the report rows?

e.g. 

March 2015 (jsmith, cmith, jcitizen, ...) 5

April 2015 (fsmith, jlaws, ...) 13

Thank you for any help.

In reply to Jason Lane

Re: Help to build a report: new user accounts per month

by Luis de Vasconcelos -

You are already selecting from the mdl_user table so just add the username column, like this (roughly and untested!):

SELECT
    d.DATE,
    d.COUNT,
    '(' + d.username + ')'
FROM
    (
      SELECT
        u.timecreated,
        DATE_FORMAT(FROM_UNIXTIME(u.timecreated), '%M %Y') AS DATE,
        u.username,
        (CASE WHEN (u.deleted = 0) THEN 1 ELSE 0 END) AS COUNT
      FROM
        mdl_user AS u
      GROUP BY
        YEAR(FROM_UNIXTIME(u.timecreated)) MONTH(FROM_UNIXTIME(u.timecreated)), u.username, u.deleted
    ) AS d