SELECT YEAR(`mt_dateCreated`) as YYYY, MONTH(`mt_dateCreated`) as MM ,DAY(`mt_dateCreated`) as DD, `mt_trackingStatus`, count(*)
FROM `smg_mt`
WHERE `mt_trackingStatus` = "20029"
AND `_id` >= (SELECT `_id` FROM `smg_mt` WHERE `mt_trackingStatus`="20029" ORDER BY `mt_dateCreated` ASC LIMIT 1)
GROUP BY YYYY ASC, MM ASC, DD ASC
LIMIT 100

Add a code snippet to your website: www.paste.org