本篇文章主要介绍了"sql语句集合 SQL 语句记录不定时更新",主要涉及到sql语句集合方面的内容,对于SqlServer感兴趣的同学可以参考一下:
1.数值四舍五入,小数点后保留2位round() 函数是四舍五入用,第一个参数是我们要被操作的数据,第二个参数是设置我们四舍五入之后小数点后显示几位。numer...
1.数值四舍五入,小数点后保留2位
round() 函数是四舍五入用,第一个参数是我们要被操作的数据,第二个参数是设置我们四舍五入之后小数点后显示几位。
numeric 函数的2个参数,第一个表示数据长度,第二个参数表示小数点后位数。
示例如下:
-- 4.56selectcast(round(4.564,2) as numeric(5,2));
-- 4.57selectcast(round(4.565,2) as numeric(5,2));
-- 4.57selectcast(round(4.566,2) as numeric(5,2));
-- 将 numeric 转换为数据类型 numeric 时出现算术溢出错误。1234.567 长度为7,大于5,故报错。selectcast(round(1234.567,2) as numeric(5,2));
-- 1234.57selectcast(round(1234.567,2) as numeric(18,2));
以上就介绍了sql语句集合 SQL 语句记录不定时更新,包括了sql语句集合方面的内容,希望对SqlServer有兴趣的朋友有所帮助。
本文网址链接:http://www.codes51.com/article/detail_4503422.html