Mysql
 sql >> Base de données >  >> RDS >> Mysql

MySQL combinant COUNT, MAX et SUM

Essayez ceci :

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;