Pregunta

I already count inscriptions, this week. But i need to count inscription per week last 12 weeks, and send it in an array.

My actual request is :

SELECT COUNT(*) FROM PERSON
YEAR(date_inscription) = YEAR(NOW())
AND WEEK(date_inscription) = WEEK(NOW())
¿Fue útil?

Solución

SELECT YEARWEEK(date_inscription) as yweek,
       COUNT(*) as cnt
FROM PERSON
where YEARWEEK(date_inscription) >= YEARWEEK(curdate()) - 12
group by yweek
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top