【发布时间】:2014-05-31 01:59:15
【问题描述】:
我为保险环境开发软件,因此十进制值非常重要。 我们正在从 MSSQL 转换为 MYSQL。我的问题涉及的查询是:
SELECT CAST(
CAST(
(initialpremium - totalpremium) / 2 *
CAST(premiummultiplier AS INT)
AS FLOAT)
FROM policy
/* rest of the query... */
此代码在 MSSQL 中有效,但在 MYSQL 中无效。 This is valid cast types for mysql。
我的问题是,浮点数的正确十进制长度是多少。 This link does not help. But describes converting from float to real in MSSQL 和我在网上搜索了float datasize mssql。
【问题讨论】:
-
我找到了答案。而不是在 mysql 中指定十进制值,您只需将代码更改为 cast(value as DECIMAL)
标签: mysql sql-server type-conversion floating-point-precision