日期:2014-05-17 浏览次数:20603 次
seelct cast (col as decimal(18,5)) from tb
------解决方案--------------------
ROUND函数可以指定需要四舍5入的小数位数!
------解决方案--------------------
推荐三个函数你可以去查查资料看看
ROUND() CEILING() FLOOR()
------解决方案--------------------
转换为数值类型
使用
numeric(18,5) decimal(18,5)
------解决方案--------------------
--> 测试数据:[tb] IF OBJECT_ID('[tb]') IS NOT NULL DROP TABLE [tb] GO CREATE TABLE [tb]([col] NUMERIC(12,5)) INSERT [tb] SELECT 112.3 UNION ALL SELECT 54665.65879 UNION ALL SELECT 456.02046 UNION ALL SELECT 654.265 UNION ALL SELECT 40354.10203 UNION ALL SELECT 145 UNION ALL SELECT 6546463 --------------开始查询-------------------------- SELECT * FROM [tb] SELECT CAST(col AS FLOAT) FROM [tb] ----------------结果---------------------------- /* (无列名) 112.3 54665.65879 456.02046 654.265 40354.10203 145 6546463 */
------解决方案--------------------
CAST(列名 AS FLOAT)