Ver originalSELECT t1.id, COUNT(t1.id) AS totalFROM tabla t1LEFT JOIN tabla t2 ON(t1.id = t2.parent)GROUP BY t1.idORDER BY total DESC