如何获得Round()的第二个参数来处理列? [英] How to get second argument of Round() to work with columns?
本文介绍了如何获得Round()的第二个参数来处理列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有整数列的简单表:
I've a simple table with an integer column:
# setup table:
create table t(x int); insert t select 1;
查询从t $ c选择一轮(1.234,1) $ c>根据预期返回
1.2
但是, select round(1.234,x )从t
返回 1.2000
。 (它应该返回 1.2
,作为根据文档。)
However, select round(1.234, x) from t
returns 1.2000
. (It should return 1.2
, as per the docs.)
这是一个错误? (测试版本 5.5.10
和最新的 5.6.24
。)
Is this a bug? (Tested on version 5.5.10
and latest 5.6.24
.)
或者,是否有任何特定的技术为什么列不能用于圆的第二个参数
?
Or, is there any particular technical reason why columns cannot be used in the second argument of round
?
我们如何获得 round
即使在第二个参数中使用列
How can we get round
to work even while there are columns used in the second argument?
推荐答案
请考虑使用 FORMAT
而不是 ROUND
:
mysql> SELECT FORMAT(1.234, x) FROM ( SELECT 1 AS x ) y;
+------------------+
| FORMAT(1.234, x) |
+------------------+
| 1.2 |
+------------------+
如果不满意,提交错误关于 ROUND
。
这篇关于如何获得Round()的第二个参数来处理列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文