• ashok_raja (3/2/2010)


    Hi,

    Yep we can use the last one.

    Can this done in a SQL Query?

    Thanks

    It depends.

    Usually, a SQL query will rely on some logic requirement(s). If both results are possible, which one has to be used as a base to determin "the next row"?

    Let's assume your next row would look like the following (ignore the wrong math. I didn't bother to calculate the new RunningTotal value).

    ID CODE Value Volume RunningTotal

    1 120 46 379646 660329

    If we would use the logic from your previous statements, the the result would be 45.

    But if we'd also consider your last statement, the result would be either 45 or 46.

    That's possible to do with SQL as well. But the question is: What is the correct answer? And why?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]