Domanda

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())
È stato utile?

Soluzione

SELECT YEARWEEK(date_inscription) as yweek,
       COUNT(*) as cnt
FROM PERSON
where YEARWEEK(date_inscription) >= YEARWEEK(curdate()) - 12
group by yweek
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top