Direi che hai quasi centrato l'obiettivo "SELECT COUNT(id) from carrello GROUP BY id" Così dovrebbe fare quello che ti serve
Regole del Forum