I must be a total idiot or something. I'm using Microsoft SQL Server 2008. I can't do simple division. SELECT 200/600 returns a big fat goose egg (0.00). Yet if I do 600/200 it returns 3. The only thing I can think of is some server setting. I'm feeling pretty darn stupid here. Can somebody please help?
Asked
Active
Viewed 468 times
1 Answers
5
The numbers you are using are being interpreted as integers, hence values you might not normally expect.
Try this...
select 200.0/600.0
and you'll see that SQL Server treats the numbers as floats and therefore gives you the result you want.
Alternatively you could try
select cast (200 as float) / cast (600 as float)
And you'd get the same result - all I've done here is to explicitly cast the values as floats.

Mat Richardson
- 3,576
- 4
- 31
- 56
-
That did it! Thanks much! – Gregbert Mar 15 '16 at 14:06