I want to calculate the percentage of elected people for each member type, I was able to do this:
SELECT Member, COUNT(Name) * 100 /
(SELECT COUNT(*) FROM 'results' WHERE Member= '1' ) AS 'perc'
FROM 'results'
WHERE elected='yes' AND Member = '1'
但我想为所有成员值做这件事(也是'0')
我的表如下所示:
Name member Elected
----------------------------
joe 0 yes
ann 1 no
jef 0 no
这是我想要的结果:
Member Percentage
---------------------
0 50%
1 0%