Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mkgmahi
Starting Member
24 Posts |
Posted - 2011-09-06 : 03:41:39
|
| I need to find the cumulative sum of qty for the a particular month. How can i do it.The problem is The qty comes from different dates I tried the below sql but not workingSELECTa.DayCount, a.Sales, SUM(b.Sales) AS RunningTotalFROM Sales aJOIN Sales b ON b.DayCount <= a.DayCountGROUP BY a.DayCount, a.SalesORDER BYa.DayCount, a.Sales |
|
|
mkgmahi
Starting Member
24 Posts |
Posted - 2011-09-06 : 03:45:05
|
| I need the Report the below way. My parameter is from and todate should be given for a particular monthDate Qty totalqty02/07/2011 20 2004/07/2011 10 3005/07/2011 -10 20Could you please help me out for the solution |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-06 : 04:49:22
|
something likeselect t.date,t.qty,t1.cumtotalfrom table tcross apply (select sum(qty) as cumtotal from table where date<=t.date) t1 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|