鉴于DOUBLE(无法更改),如何按格式化列的总和进行排序?
+------+-----+
| id | val |
+------+-----+
2 | 1289.42
2 | 43.21
3 | 90.02
根据我的尝试,似乎订单只是按前几位排序:
select format(sum(val), 2)
group by id
order by val DESC
如果我尝试使用别名
,结果是一样的select format(sum(val), 2) as res
group by id
order by res DESC
当前输出:
90.02 <--- looks to only order by first few numbers
1,332.63
期望的输出:
1,332.63 <----higher values first
90.02