Change GROUP BY project_id to GROUP BY p.name,p.id
The docs say:
When GROUP BY is present, it is not valid for the SELECT list expressions to refer to ungrouped columns except within aggregate functions, since there would be more than one possible value to return for an ungrouped column.