1.数值四舍五入,小数点后保留2位数据库
round() 函数是四舍五入用,第一个参数是咱们要被操做的数据,第二个参数是设置咱们四舍五入以后小数点后显示几位。ide
numeric 函数的2个参数,第一个表示数据长度,第二个参数表示小数点后位数。函数
示例以下:spa
-- 4.56 select cast(round(4.564,2) as numeric(5,2)); -- 4.57 select cast(round(4.565,2) as numeric(5,2)); -- 4.57 select cast(round(4.566,2) as numeric(5,2)); -- 将 numeric 转换为数据类型 numeric 时出现算术溢出错误。1234.567 长度为7,大于5,故报错。 select cast(round(1234.567,2) as numeric(5,2)); -- 1234.57 select cast(round(1234.567,2) as numeric(18,2));
2.SQL从数据库中随机查询数据.net
通常来讲,例如在表A中随机查询5条数据,语句以下:code
SELECT TOP 5 * FROM A ORDER BY NEWID()
参考:https://blog.csdn.net/manyidemanyi/article/details/8166154blog