I have query that counts the number of distinct values of a given field for a given week that where not recorder before. It counts the number of new values for the week.
SELECT COUNT(DISTINCT (field)) FROM table WHERE (creation BETWEEN CURDATE() - INTERVAL DAYOFWEEK(CURDATE()) + 5 DAY AND CURDATE() - INTERVAL DAYOFWEEK(CURDATE()) - 2 DAY) AND field NOT IN (SELECT DISTINCT (field) FROM table WHERE creation < CURDATE() - INTERVAL DAYOFWEEK(CURDATE()) + 5 DAY); I need to extend the query to be able to do the same computation for all the weeks in the past two months.
How can I do it?