• haddoque2000 (5/13/2014)


    ...

    Sample rows:

    FinKeyDateKeyOrgaKeyCliKeyAccoKeyDim1KeyDim2KeyAmountDate

    19720101001113611-541261,822010-10-01 00:00:00.000

    19820101031113611-541261,822010-10-31 00:00:00.000

    19920101101113611-550252,822010-11-01 00:00:00.000

    20020101201113611-559243,822010-12-01 00:00:00.000

    20120110131113611-568234,822011-01-31 00:00:00.000

    2022004050611117116103332004-05-06 00:00:00.000

    2032004050711117111436942004-05-07 00:00:00.000

    204200405101111711-1466222004-05-10 00:00:00.000

    205200405111111711-1595222004-05-11 00:00:00.000

    ...

    Had you read the article suggested by Jeff and others you would have posted this as INSERTs. We're now two days into your problem and haven't made any progress whatsoever. Remember what I said earlier - "Coding up a running totals script is easy...". Read the article and post the sample data in the way it recommends.

    Your first post states "I have a table with monthly sums for assets and liabilities. I need a running total for each of the accounts." For this table only, post the ddl and some sample data as the source, and similar scripts for the expected result set.

    Also, please clarify whether you need to update a table (as part of a data load or whatever) or return the running total as part of result set.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden