Link to home
Start Free TrialLog in
Avatar of redzoneglobal
redzoneglobal

asked on

Arithmetic calculation in SQL Select not correct

select top 10 statspartner.campaignid, statsc.campaignname, statspartner.partnerid, statspartner.pdate, statspartner.kw, statspartner.clicks, statspartner.actions, ((statspartner.actions / statspartner.clicks) * 100) as conversion from statspartner, statsc where statspartner.ProjectID = "14" and pdate = "07/16/08" and statspartner.clicks <> 0 and (statspartner.campaignid = statsc.campaignid) order by statsc.campaignname, clicks desc

In the above example if statspartner.clicks = 24209 and statspartner.actions = 72 then conversion should be equal to .297, but the output of the query displays "0".  If statspartner.clicks = 1, statspartner.actions = 1, conversion accurately displays "100".  Any other values for clicks/actions displays zero..
ASKER CERTIFIED SOLUTION
Avatar of mastoo
mastoo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of redzoneglobal
redzoneglobal

ASKER

Yes, they were.  I'd done calcs before, but I guess never ran into the INT issue previously..  Txs for the fast reply/solution!
declare @a int
declare @b int
select @a = 10;
select @b = 3
select @a/@b
-->
results in 3
select convert(float,@a)/convert(float,@b)
->
results in 3.33333333