Hi, I have a result from my multiple CTE scripts but I have a hard time on how to get the cumulative value.
below is a sample ddl and result set.
[code]create table #sample
(sdesc nvarchar(35), qty int, share numeric(12,2), defect numeric(12,2),rownum int)
insert into #sample(sdesc,qty,share,defect,rownum)values('Locked',31407,0.272254440485787,0.298452006499862,1)
insert into #sample(sdesc,qty,share,defect,rownum)values('Corroded',8590,0.074463197496510,0.081628386532741,2)
insert into #sample(sdesc,qty,share,defect,rownum)values('power on',5543,0.048050000433429,0.052673590983816,3)
insert into #sample(sdesc,qty,share,defect,rownum)values('high current',4490,0.038921974011563,0.042667224159721,4)
insert into #sample(sdesc,qty,share,defect,rownum)values('Failure',3783,0.032793280108184,0.035948799331008,5)
insert into #sample(sdesc,qty,share,defect,rownum)values('low current',2841,0.024627467297740,0.026997234707743,6)
SAMPLE DESIRED RESULT
sdesc-------------qty----share %-------------defect %==========RowNum--new column percentage
Locked-----------31407--0.272254440485787---0.298452006499862---1-----0.272254440485787
Corroded---------8590---0.074463197496510---0.081628386532741---2-----0.074463197496510+0.272254440485787
power on---------5543---0.048050000433429---0.052673590983816---3-----0.048050000433429+0.074463197496510
high current-----4490---0.038921974011563---0.042667224159721---4-----0.038921974011563+0.048050000433429
Failure----------3783---0.032793280108184---0.035948799331008---5-----0.032793280108184+0.038921974011563
low current------2841---0.024627467297740---0.026997234707743---6-----0.024627467297740+0.032793280108184[/code]