Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Output in Decimal.

Author  Topic 

hspatil31
Posting Yak Master

182 Posts

Posted - 2012-02-07 : 06:28:46
Hello All,

I am tryin following SQL statement but I am not getting proper output,
SELECT (200*100)/400000
I am getting output 0 but It should shows 0.05.

Can anybody please tell me how to resolve this issue ?




Thanks and Regard's
Harish Patil

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-02-07 : 06:48:23
It is because of integer division. Force to decimal by changing at least one of those to decimal - for example:
SELECT (200*100.00)/400000
Or
SELECT (200*100*1.0)/400000
Go to Top of Page
   

- Advertisement -