我有一个表结构columns Site, Item Amount,Item Weight
。我想计算每个网站的百分比。我试过这个查询,但得到错误的%值。请帮忙。计算每个站点的mysql的百分比
Site | Item Amount | Item Weight
A | 1000 | 50
B | 800 | 35
C | 1500 | 65
Select Site, sum(Item Amount) As Amount, sum(Item Weight)
AS MT,concat(round((Item Amount/sum(Item Amount)*100),2),%)
AS percentage from 'table1' group by site.
等等......你想要多个列的百分比吗? –
显示一些数据或表结构和所需的输出。 –
你的名字中有空格吗?用**'**在你的queryAnyway中保护它们,你应该使用'%'而不是% 并且不需要使用'table1',table1就可以。 –