rolling total trouble

  • So I have the following syntax:

    Select

    i.Amount as Balance

    From

    ARHeader h

    join ARDetail d on h.Voucher = d.Voucher and h.CompCode = d.CompCode

    join ARItem i on d.[LineNo] = i.[LineNo] and d.Voucher = i.Voucher

    Where

    i.CompCode='Will' and h.AID=475568982 and d.TransNo=0

    Except that I need i.Amount to be displayed as a rolling total for every row. I've tried a million syntaxes and I just can't figure it out

  • If you can provide some sample data and table structure that would help us help you.

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • it contains sensitive material, can i show you an example?

  • Actually, before doing that, spend some time reading this great article[/url] posted by Jeff Moden. Then, if you still have questions feel free to post them here, but do read the article first.

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Please read the best article ever written for running totals on SQL Server[/url] by MVP Jeff Moden.

    If you still need assistance, please read the first link in my signature for how you can help us help you get better, tested answers faster.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • omri.wallach (6/8/2010)


    So I have the following syntax:

    Select

    i.Amount as Balance

    From

    ARHeader h

    join ARDetail d on h.Voucher = d.Voucher and h.CompCode = d.CompCode

    join ARItem i on d.[LineNo] = i.[LineNo] and d.Voucher = i.Voucher

    Where

    i.CompCode='Will' and h.AID=475568982 and d.TransNo=0

    Except that I need i.Amount to be displayed as a rolling total for every row. I've tried a million syntaxes and I just can't figure it out

    Omri,

    It doesn't have to be real data. Just a representation of the problem. Don't assume that you know how to post it, though. See the article at the first link in my signature line below. If you post data and a table creation as outlined in the article, people will trip over each other trying to help.

    --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)

  • WayneS and bteraberry... thanks for the great kudo. :blush:

    --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 7 posts - 1 through 6 (of 6 total)

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