我的数据示例:
+----------+--------+------------+-------------------+
| Category | Orders | Units | Value |
+----------+--------+------------+-------------------+
| RED | 165 | 9,376,638 | $723,544,659.20 |
| BLUE | 106 | 6,709,972 | $421,713,725.59 |
| ORANGE | 136 | 6,118,278 | $229,171,543.85 |
| GREEN | 25 | 1,281,459 | $52,194,155.69 |
| OTHER | 17 | 301,056 | $9,493,416.87 |
| Totals | 449 | 23,787,403 | $1,436,117,501.20 |
+----------+--------+------------+-------------------+
这有效:
, SUM(red) *1.0 / count(*) as red_perc
但是当我尝试根据价值而不是单位找到每个百分比时,我没有得到一个百分比,这个数字是1710688.272437
, SUM(red_total) *1.0 / count(*) as red_value_perc
有人可以找到我出错的地方吗?我不明白为什么一个有效,一个没有。