[英]Convert decimal number to INT SQL
I want to convert the decimal number 3562.45 to 356245, either as an int
or a varchar
.我想将十进制数 3562.45 转换为 356245,作为
int
或varchar
。 I am using cast(3562.45 as int)
, but it only returns 3562. How do I do it?我正在使用
cast(3562.45 as int)
,但它只返回 3562。我该怎么做?
显而易见的是:
CAST(3562.45*100 as INTEGER)
这对我有用
SELECT FLOOR(55.5999)
Or you can replace the decimal point. 或者您可以替换小数点。
select cast(replace('3562.45', '.','') as integer)
This way, it doesn't matter how many decimal places you have. 这样,你有多少小数位并不重要。
您还可以使用CONVERT函数:
SELECT CONVERT(INT, 3562.45 * 100)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.