sql >> Database teknologi >  >> RDS >> Mysql

MySQL kombinerer COUNT, MAX og SUM

Prøv dette:

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;


  1. JDBC ResultSet intern mekanisme til at hente store datasæt

  2. Sådan bruger du stopord og stopliste til at forbedre SQL Server Full-Text Search (FTS)

  3. Rails 5 Mysql UUID

  4. Genialt SQL Password Changer Utility til at nulstille SQL Password