Help to build a report: new user accounts per month

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

by Luis de Vasconcelos -
Number of replies: 0

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