SELECT
WEEK (
DATE_FORMAT(
date_add(
DATE_FORMAT(
DATE_ADD(NOW(), INTERVAL - 3 MONTH),
'%Y-%m-%d'
),
INTERVAL (
cast(
help_topic_id AS signed INTEGER
)
) DAY
),
'%Y-%m-%d'
)
) weekInfo
FROM
mysql.help_topic
WHERE
help_topic_id < datediff(
DATE_FORMAT(CURDATE(), '%Y-%m-%d'),
DATE_FORMAT(
DATE_ADD(NOW(), INTERVAL - 3 MONTH),
'%Y-%m-%d'
)
) + 1
GROUP BY weekInfo