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
 % calc producing zeroes

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2010-09-28 : 08:57:44
(RC)/GT*100 as ReportPercent

The above line is meant to be calculating percentages but producing zeros.
this is perhaps an integer issue: integer dividing integer.

I have tried CAST and FLOAT but not quite working.

Many thanks!


harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2010-09-28 : 09:06:04
Try

(RC)/GT*100.0 as ReportPercent


Harsh Athalye
http://www.letsgeek.net/
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2010-09-28 : 09:19:30
Harsh,

Now I just get 0.00 as opposed to 0
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-09-28 : 09:24:20
quote:
Originally posted by tariq2

Harsh,

Now I just get 0.00 as opposed to 0



(RC)*1.0/GT*100.0 as ReportPercent

PBUH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-28 : 09:29:54
Also read this
http://beyondrelational.com/blogs/madhivanan/archive/2008/01/16/beware-of-implicit-conversions.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2010-09-28 : 09:46:38
Thank you guys, works a treat :)
Go to Top of Page
   

- Advertisement -