Podrías usar: SELECT name, SUM(count) FROM table_name WHERE date >= ( CURDATE() - INTERVAL 30 DAY ) GROUP BY name;