Home Forums SQL Server 2008 SQL Server 2008 - General Looping through the recordset to assign different balance value to each transaction row RE: Looping through the recordset to assign different balance value to each transaction row

  • yogesh_pandey (10/6/2010)


    Thank you for the reply. But the cur balance is in one table and the transaction is in another. I would have to use cur balance and remember the previous cur balance to calculate cur_bal for the previous transaction as I go up the list. I don't know if i make any sense. Please let me know.

    the concept is still the same.; it's still a running total type of situation.

    you join the main table to the transaction table to get the starting row and all the child rows. those two tables joined together are a query(just like the example data i posted);

    then you can join them together, offset by a row_number() function.

    without you providing the actual CREATE TABLE definitions and some sample data in a consumable format, like i posted, all i can do is offer concepts on how to tackle the issue.

    or of course you could help us help you....

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!