Mysql
 sql >> Database >  >> RDS >> Mysql

MySQL filtra i risultati per mese e anno

Basta usare MESE() e ANNO() funzioni

SELECT COUNT(*) as `count`,
      `region`, 
       YEAR(`date`) as `year`,
       MONTH(`date`)  as `month`
   FROM my_stores.stats 
        WHERE  YEAR(`date`) in (2012,2013)
 GROUP BY `region`, YEAR(`date`),MONTH(`date`)