Forum Discussion
what is the reason?
Hi SanyaSan -- I think the difference between the two is the result of data type precedence within a CASE statement. They "incorrect" query uses a CASE statement and according to data type precedence rules, numeric/decimal is higher than money and will therefore produce a numeric data type value.
The "correct" query of course has no CASE statement and is explicitly setting the @IngQtyLackInGoods variable which has the money datatype. Therefore, this query is not impacted by data type precedence. Take care.
- SanyaSanMay 19, 2022Copper Contributor
Thanks man
But I didn't understand why there is no error in the second piece of code (IF...)Also, in the first piece of code, if you fix the first branch of CASE (CEILING) calculations, for example, put 10000 instead of 10000.00, the second branch begins to count correctly, why does it even climb to calculate CEILING (CEILING, despite the fact that @GoodsCountable = 0 ?