Redian新闻
>
for round() function in SQL
avatar
for round() function in SQL# Database - 数据库
e*r
1
I used the following command to format the data output, but got some
wired data. What is the reason? Thanks
select round( ( ( bestbid + bestoffer) /2 ) / 0.05 , 0 ) * 0.05
as mbbo from table;
mbbo
34.200000000000003
14.25
6.2000000000000002
45.650000000000006
10.15
1.1500000000000001
4.5499999999999998
0.70000000000000007
3.4000000000000004
13.25
6.0
12.0
5.0500000000000007
1.4000000000000001
28.25
0.65000000000000002
20.950000000000003
0.30000000000000004
2.8000000000000003
0.700000
avatar
a*t
2
don't know
but if you want to format data, use cast
avatar
e*r
3
你说的 CAST 就是指 CONVERT FUNCTION 吧?

【在 a*******t 的大作中提到】
: don't know
: but if you want to format data, use cast

avatar
a*t
4
cast and convert are basically the same
either one is fine

【在 e******r 的大作中提到】
: 你说的 CAST 就是指 CONVERT FUNCTION 吧?
avatar
c*e
5
round off error? I guess it's introduced by the 0.05
try it without 0.05; if not then use cast

【在 e******r 的大作中提到】
: 你说的 CAST 就是指 CONVERT FUNCTION 吧?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。