Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculating cumulative totals

Status
Not open for further replies.

mjd3000

Programmer
Apr 11, 2009
136
GB
I have the following SQL and I want to add a column for the Evidence field showing cumulative totals for each grouping of programme/programme contract/output for each month. Can anybody help?



select targ.new_programmemoidname as 'Programme', targ.new_programcontracouttidname as 'Programme Contract',
targ.new_monthlyoutputsidname as 'Output',
targ.new_monthnumber as 'Month', targ.new_numberofoutputs as 'Outputs',
count(act.new_outputevmonthnumber) as 'Evidence'
from FilteredNew_monthlyoutput targ
left join FilteredNew_evidence act
on targ.new_monthlyprofileoutid = act.new_claimperiodid
and targ.new_monthlyoutputsid = act.new_evidenceforoutputid
group by targ.new_programmemoidname, targ.new_programcontracouttidname, targ.new_monthlyoutputsidname,
targ.new_monthnumber, targ.new_numberofoutputs
order by targ.new_programmemoidname, targ.new_programcontracouttidname, targ.new_monthlyoutputsidname,
targ.new_monthnumber
 
Hi,

The difference between what I am trying to do and the typical cumulative total field is that the field I want cumulative totals for is a count of total records in a table related to a particular grouping of programme/programme contract/output/month.
 
I understand and it makes this problem even more trickier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top