I've got a view with the following data: (Sample)
Class Date Month Year Day Target Actual Variance MName
====================================================================
DropBalling 01/07/2005 7 2005 1 165000 117850 -47150 July
DropBalling 02/07/2005 7 2005 2 165000 92550 -72450 July
DropBalling 03/07/2005 7 2005 3 165000 171900 6900 July
DropBalling 04/07/2005 7 2005 4 165000 66850 -98150 July
Lancing 01/07/2005 7 2005 1 90000 44100 -45900 July
Lancing 02/07/2005 7 2005 2 90000 129650 39650 July
Lancing 03/07/2005 7 2005 3 90000 85450 -4550 July
Lancing 04/07/2005 7 2005 90000
Plant 01/07/2005 7 2005 67000
Plant 02/07/2005 7 2005 2 67000 18150 -48850 July
Plant 03/07/2005 7 2005 3 67000 6150 -60850 July
Plant 04/07/2005 7 2005 67000
I want to create a chart, which looks like this: http://www.tjoppie.co.za/chart.jpg .. So what I'll have to do is "cummilate sum" everyday's targets and actuals. How can I do this?
Thanks
RudiI couldn't understand exactly what type of sums you want to generate. Below is an example of how cumulative sums are typically generated in SQL. The example users northwind table and you can adapt this technique to your needs:
select o1.OrderID, o1.ProductID, sum(o2.UnitPrice), sum(o2.Quantity), sum(o2.Discount)
from Northwind.."Order Details" as o1
join Northwind.."Order Details" as o2
on o1.ProductID = o2.ProductID and o2.OrderID <= o1.OrderID
where o1.ProductID = 9
group by o1.OrderID, o1.ProductID
|||Thanks,
That did the job.
No comments:
Post a Comment