Calculation of percentage of group count(*)

前端 未结 4 718
没有蜡笔的小新
没有蜡笔的小新 2021-01-01 02:58
Select * from Namelist;
Name      Age
Sathish   25
Sathish   65
Sathish   55
Sathish   45
Sathish   35
Jana      55
Jana      25
Jana      10
Bala      55
Bala               


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 03:25

    This query(not tested) should work :

    SELECT Name,
    COUNT(*) AS Count,
    (COUNT(*) / _total ) * 100 AS Percentege
    FROM Namelist,
    (SELECT COUNT(*) AS _total
      FROM Namelist) AS myTotal
    GROUP BY Name;
    

提交回复
热议问题