sql >> Base de Datos >  >> RDS >> Mysql

MySQL combinando COUNT, MAX y SUM

Prueba esto:

SELECT COL1,Max(COUNT_ID),Sum(SUM_MAX_COUNT) FROM(
SELECT COL1,
   Count(*) AS COUNT_ID,
   (SELECT Sum(Count(*))
    FROM   TABLE_NAME
    GROUP BY COL1) AS SUM_MAX_COUNT
FROM   TABLE_NAME
GROUP  BY COL1)
GROUP BY COL1;