Adding rows in same table for different period

  • Hi, I need your expertise on this issue. Basically the reason to do this is to calculate YTD values.

    For example, I have the following data:

    org acc period amount

    --------------------------

    SSD ASSET 01/2011 10

    SSD ASSET 02/2011 15

    SSD ASSET 03/2011 20

    Based on the example above, I intend to get the following result set:

    org acc period amount

    --------------------------

    SSD ASSET 01/2011 10

    SSD ASSET 02/2011 15

    SSD ASSET 03/2011 20

    SSD ASSET YTD(01/2011) 10

    SSD ASSET YTD(02/2011) 25

    SSD ASSET YTD(03/2011) 45

    Any help you can provide with be greatly appreciated.

  • I do not think that you would want new rows. Adding a new column to hold the sum YTD would suffice. Search the forum for rolling sum posts. They should lead you in the right direction.

    Hope that this helps...thanks.

    - Chris

  • Here is the article I think Chris was alluding to:

    http://www.sqlservercentral.com/articles/T-SQL/68467/[/url]

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply