In my Symfony app I have an entity 'Project' which contains two fields: 'createdOn' (type = date) and 'individual'. An individual can occur multiple times in 'Project'.
_created_On_|_individual_id
2012.12.01 | 3
2012.12.24 | 5
2013.01.10 | 9
I'm trying to build a query to count all distinct individuals grouped by 'createdOn' in such a way, that I get results sorted by month. And it must be possible to set a date range for the query.
My query so far:
'SELECT p.createdOn, COUNT (DISTINCT p.individual)
FROM ...\DossierBundle\Entity\Project p
WHERE p.createdOn
BETWEEN :name1
AND :name2'
)->setParameters(array(
'name1' => $startDate,
'name2' => $endDate,
))
This doesn't quite get me the desired result below
_DATE____|_Number_of_Individuals
Dec 2012 | 2
Jan 2013 | 1
But instead I get
__DATE_____|_Number_of_Individuals
2012.12.01 | 1
2012.12.24 | 1
2013.01.10 | 1
Google didn't help me either so any support will be much appreciated.
Flo