Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

MySQL combinando COUNT, MAX e SUM


Tente isto:
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;