Was floored to learn this, surely I am making and error...
If I DECLARE
a real (or decimal) local variable I can't assign (SET
) the value of an expression? I have to set to a value first then step through the expression. If I try to "do the math" all at once I get 0
.
So, this works..
DECLARE @HitRate real
SET @HitRate = 805499
SET @HitRate = (@HitRate / 847125) * 100
--SET @HitRate = (805499 / 847125) * 100 --But this does not work?
SELECT @HitRate
- If I comment out the first 2
SET
statement and just use the the third I get0
- If I use all
3
, I get0
- If I
CAST(@HitRate As DECIMAL(9,2))
I get0