开发者

How to Truncate the Decimal Places without Rounding Up? [duplicate]

This question already has answers here: Truncate (not round) decimal places in SQL Se开发者_开发百科rver (21 answers) Closed 5 years ago.

Assume i have the following decimal value:

4.584406

I need a simple quick way to truncate the decimal without rounding up, so the output would be 4.5

I'm using T-SQL (SQL Server 2005/2008).

Any help will be appreciated.


using the round function you can try this

select round(4.584406, 1, 1)

the output will be

4.5

the key is the third parameter

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜