Ver originalSELECT Id_Pedido, COUNT(*) AS conteo FROM Detalles GROUP BY Id_Pedido ORDER BY conteo DESC