How to calculate sum of row

  • Understood, but not exactly what I meant... I meant what they do behind the scenes to generate the running total... must be a "machine language" cursor of sorts to get some speed out of it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Carla Hepker (8/4/2008)


    Jumping in...

    I assume each debit and credit is associated with a user identifier and has a post date time stamp. If that is the case, it seems to me that you should be able to do a view, grouping by the user identifier where you subtract the sum of the credits from the sum of the debits. You could get a point in time balance by including an ending date in a where clause.

    Yep.. I agree... point in time balances are just a SUM limited by criteria and no "triangular join" is involved. Running balances on each row is a bit different. You mentioned a view for this... I'd love to see someone do it in a view without the use of a performance killing "triangular join". Not being a smart guy about this, either. It would be revolutionary if someone could actually pull it off. 🙂

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 16 through 16 (of 16 total)

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