$SQL="SELECT tv , COUNT(*) FROM Tabla GROUP BY tv" tv | count(*) Categoria1 | 1 Categoria2 | 13 Categoria3 | 12 Categoria4 | 24