I am trying to get the all records which are 2 hours or more old using this query:
$minutes = 60 * 2 SELECT COUNT(id) AS TOTAL, job_id from tlb_stats W
You can also do it in this way:
$minutes = 60 * 2 SELECT COUNT(`id`) AS `TOTAL`, `job_id` FROM `tlb_stats` WHERE `log_time` < NOW() - INTERVAL $minutes MINUTE GROUP BY `job_id`