我想计算积极投票和消极投票的百分比。例如,我有大约 5 票赞成票和 5 票反对票,它应该是 50%,对吗?
如何在 mysql/php 查询中做到这一点?
各列如下所示:
no yes yes no no no no yes yes yes
最佳答案
select id,
100 * sum(vote_column = 'yes') / count(vote_column) as percentage
from your_table
group by id
关于PHP mysql 计算两列之间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21340388/