开发者

How to calculate the percentage of a column in mysql

开发者 https://www.devze.com 2023-03-13 09:42 出处:网络
I have a table with some number fields an开发者_运维问答d I want to get calculate the percentage of each value in that field. Which means I want to get the sum of the column and divide by it the every

I have a table with some number fields an开发者_运维问答d I want to get calculate the percentage of each value in that field. Which means I want to get the sum of the column and divide by it the every row and to multiply by 100. But it doesn't work. Can u help me?


Like this?

select OrderQty * 100.0 / (select sum(OrderQty) from SalesOrderDetail)
from SalesOrderDetail
0

精彩评论

暂无评论...
验证码 换一张
取 消