Why is ROUND(2.05, 1)
producing 2.0
? Isn't supposed to produce 2.1
?
Thanks for helping
SELECT
p.AdjustPercent,
CAST(CAST(ROUND(p.AdjustPercent, 1) AS DECIMAL(10, 1)) AS VARCHAR(50)) + '%',
....
I've got things like
2.38 2.4%
2.05 2.0%
I think I know what your problem is. Is your type a float? Bear in mind that 2.05 float can well be 2.049999998. Hence it rounds down.
Try the following:
DECLARE @f float = 2.05
DECLARE @d decimal(10,2) = 2.05
DECLARE @n numeric(10,4) = 2.05
SELECT ROUND(2.05, 1)
SELECT ROUND(@f, 1)
SELECT ROUND(@d, 1)
SELECT ROUND(@n, 1)
Results
2.10
2
2.10
2.1000
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments