SELECT {field_date_formatted} AS `period`, COUNT(*) AS {object} FROM {table} LEFT JOIN `sys_profiles` AS `tp` ON {table}.`id` = `tp`.`content_id` AND `tp`.`type`='bx_channels' WHERE 1 AND `tp`.`status`='active' {where_inteval} GROUP BY `period` ORDER BY {table}.{field_date} ASC