472,123 Members | 1,402 Online

# how to add in column on each day to as on day...

27
Hellow Sir,

when i group with DATE from the Table it shows this result...

DATE Amount

04/01/2009 100
04/03/2009 200
04/04/2009 300
04/05/2009 400
04/06/2009 500
04/08/2009 -700
04/09/2009 800
04/10/2009 1000
04/12/2009 200
04/13/2009 50
04/14/2009 200
04/15/2009 300
04/16/2009 400
04/17/2009 500

BUT i need to get the Result as Below...

DATE Amount Amount

4/1/2009 100 100
4/3/2009 200 300
4/4/2009 300 600
4/5/2009 400 1000
4/6/2009 500 1500
4/8/2009 -700 800
4/9/2009 800 1600

and so on...

that is ... Each day the amount should be added
for the date (04/04/2009 amount is added as 100+200+300)
Using Cursor ..... or any kind...
Problem..

Thankyou.........
Jul 28 '10 #1
3 1225
gpl
152 100+
Realistically, you should be doing this calculation in the front-end / report code, however what you need to do is to calculate the sum of all amounts for dates that are less than - or equal to - the date of the current row.

Something like this (not tested as I dont know your original code) - note that it will get very inefficient with increasing numbers of rows returned in the original query
Expand|Select|Wrap|Line Numbers
1. Select [date], amount,
2.
3. (Select Sum(Amount) from (your original query goes here) r where r.[date] LE s.[date]) as Running
4.
5. From (
6. your original query goes here
7. ) s
Aug 3 '10 #2
MrMob
27
Plz Sir..

WIll you Little Elaborate more clearly with some life good Examples..
I would be glad Enough to solve it..
Thankyou.

Your Disciples..
Aug 11 '10 #3
gpl
152 100+
If you would post the query that you developed to give you the results in your first post, I will try to give you a good example
Aug 11 '10 #4

### Post your reply

Sign in to post your reply or Sign up for a free account.

### Similar topics

 9 posts views Thread by DMAC | last post: by 3 posts views Thread by Yeah | last post: by reply views Thread by Manish | last post: by 4 posts views Thread by bei | last post: by reply views Thread by kowndinya | last post: by 5 posts views Thread by Ken | last post: by reply views Thread by Chran | last post: by 1 post views Thread by Death Slaught | last post: by 1 post views Thread by ll | last post: by 3 posts views Thread by mcfly1204 | last post: by reply views Thread by beacampos | last post: by reply views Thread by isladogs | last post: by reply views Thread by BenitoJuares | last post: by reply views Thread by bakertaylor28 | last post: by reply views Thread by leo001 | last post: by reply views Thread by antdb | last post: by 3 posts views Thread by bobbyer | last post: by 7 posts views Thread by bounthong | last post: by 5 posts views Thread by Bright1Light | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.