MSSQL - Membuat total cumulative
Wednesday, 02 November 2011 12:13
select a.calYear, a.calMonth, a.descriptionCode, a.budgetValue, SUM(b.budgetValue) cumulative
from dbo.fn_reportBSDetailMonthly('6500','2012','01','12') a
left join 
(
select calYear, calMonth, descriptionCode, budgetValue
from dbo.fn_reportBSDetailMonthly('6500','2012','01','12')
--where descriptionCode = 'BSDE-8-2-3-0000'

) b on a.calYear = b.calYear and a.descriptionCode = b.descriptionCode and a.calMonth >= b.calMonth
--where a.descriptionCode = 'BSDE-8-2-3-0000'
group by a.calYear, a.calMonth, a.descriptionCode,a.budgetValue
 
Joomla templates by a4joomla