假设我有以下十进制值:
4.584406
我需要一种简单快速的方法来截断小数而不向上舍入,因此输出将为 4.5
我正在使用 T-SQL (SQL Server 2005/2008)。
任何帮助将不胜感激。
最佳答案
使用round
功能你可以试试这个
select round(4.584406, 1, 1)
输出将是
4.5
关键是第三个参数
ROUND ( numeric_expression , length [ ,function ] )
function
Is the type of operation to perform. function must be tinyint,
smallint, or int. When function is omitted or has a value of 0 (default), numeric_expression is rounded. When a value other than 0 is specified, numeric_expression is truncated.
关于sql - 如何截去小数位而不向上舍入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3895652/