select 列1,列2 from biao1,小问题,如何对列1数字格式化,我想对它四舍五入? select 列1,列2 from biao1列1是乘出来的4位小数,我想对它四舍五入,怎么弄?解决就结!先到先得 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ROUND返回数字表达式并四舍五入为指定的长度或精度。语法ROUND ( numeric_expression , length [ , function ] ) 参数numeric_expression精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。length是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。function是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。返回类型返回与 numeric_expression 相同的类型。 select cast(列1 as dec(18,0)) as 列1,列2 from biao1--0是没有小数位,如果要保留2位小数,把0改为2 select round(列1,0),列2 from biao1 不保留小数select round(列1,0),列2 from biao1保留一位小数select round(列1,1),列2 from biao1 如何控制主键重复? sqlserver怎么查询一定条件下某一段的数据 【100分】求解:往镜像数据库主体库BCP数据失败,有什么解决方法? 一个SELECT的问题。 请问SQL Server中怎样在不删除字段的情况下,通过SQL语句的方式来修改该字段的默认值? 如何求出每15分钟的总和,最大值,最小值,平均值? 关与GROUP BY ! 数据旋转问题! 如何在触发器中向某指定端口发送TCP消息? SQL2000的问题?? 又是时间转换问题 SQL的求和运算
返回数字表达式并四舍五入为指定的长度或精度。语法
ROUND ( numeric_expression , length [ , function ] ) 参数
numeric_expression精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。length是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。function是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。返回类型
返回与 numeric_expression 相同的类型。
select cast(列1 as dec(18,0)) as 列1,列2 from biao1--0是没有小数位,如果要保留2位小数,把0改为2
select round(列1,0),列2 from biao1
select round(列1,0),列2 from biao1
保留一位小数
select round(列1,1),列2 from biao1