SQL Server 7
Hello Again,
I'm trying to calculate each row's unit percentage of total units. Here's what I'm trying:
Here's what I get:
Seems to me I should be getting 33.3%, 50%, and 16.6%, respectively. Does SQL not like to divide in the select statement?
Thanks in advance,
Jason
Hello Again,
I'm trying to calculate each row's unit percentage of total units. Here's what I'm trying:
Code:
select
stage,
b.units,
(select sum(a.units) from #temptable2 a) as TotalUnits,
(b.units / (select sum(a.units) from #temptable2 a) * 100) as PercentUnits
from #temptable2 b
Here's what I get:
Code:
stage units T.U. P.U.
bob 2 6 0
sally 3 6 0
tim 1 6 0
Seems to me I should be getting 33.3%, 50%, and 16.6%, respectively. Does SQL not like to divide in the select statement?
Thanks in advance,
Jason