all groups > sql server mseq > july 2006 >
You're in the

sql server mseq

group:

Simple Math Question


Simple Math Question Phil
7/26/2006 2:41:01 AM
sql server mseq:
Hi,

Hope someone can help with something so silly and that I feel quite ashamed
about asking, I am just doing some simple percentage calcualtions which I
have done in sql before without any problems, my query simplified is as
follows

SELECT 50 /175 * 100

If you do this on a calculator you get 28.57 ignoring the trailing figures,
if you run the above query you get ' 0 '. I am running SQL Server 2000 &
2005 and I get the same results. I am sure I am just doing something silly
but if anyone can help it would be much appreciated.

RE: Simple Math Question Phil
7/26/2006 6:16:02 AM
I have fixed this now by changing one of the figures to a Float type.

Thanks PD

[quoted text, click to view]
Re: Simple Math Question Arnie Rowland
7/26/2006 8:40:41 AM
As you discovered, it was doing integer division -resulting in a division
result of zero [0]. Adding a [.0] to either operand makes it work.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

AddThis Social Bookmark Button