Agregar un group by
SELECT content.id,
sum(likes.type = 'p') as p
FROM content
JOIN likes on likes.content_id = content.id
GROUP BY content.id
Luego, las funciones agregadas (es decir, count()
) se aplican a los grupos y no a todo el resultado.