I'm performing a calculation and I don't get the answer I expect. I lose some scale doing the calculation.
Calc is: 651/1000 * -413.72063274 = -269.33213191 (to 8 d.p)
In SQL Server I do this:
declare @var numeric(28,8)
declare @a numeric(28,8)
declare @b numeric(28,8)
set @var = -413.72063274
set @a = 651.00000000
set @b = 1000.00000000
select CAST((@a/@b) * @var as numeric(28,8)) as result_1
, CAST(CAST(@a as numeric(28,8))
/CAST(@b as numeric(28,8)) as numeric(28,8))
*CAST(@var as numeric (28,8)) as result_2
The results is
result_1: -269.33213200 (correct to 6dp)
result_2 : -269.332132 (correct to 6dp)
How do I get the query to return: -269.33213191 (correct to 8dp)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…