Filling a Table

Last post 05-08-2008, 1:42 PM by Phil Factor. 1 replies.
Sort Posts: Previous Next
  •  05-03-2008, 1:10 AM Post number 49864

    Filling a Table

    Hi All,

    I have a Table with 3 columns 

    SalesPID          SalesAmount   DiscountAmount

    12                            120             20.00
    13                            130             30.00
    14                            140             40.00

    I Need An Output Table like the Following  table which contains extra column with name RunningTotals which is sum of currentRow discountAmount and Previous row of  RunningTotal Value.Is it Possible to fill a temporary table or tableVariable or commonTableExpressions or using any other statements without using cursor or looping statements.

    SalesPID          SalesAmount   DiscountAmount      Running Totals

    12                            120                      20.00                20.00
    13                            130                      30.00                50.00
    14                            140                      40.00                90.00

    Awaiting Your Valuable Inputs

    Thanks and Best Regards,

    Rajesh

     

  •  05-08-2008, 1:42 PM Post number 51586 in reply to post number 49864

    Re: Filling a Table

    Yes, you can do a running total using Robyn Page's quirky update technique.
    http://www.simple-talk.com/sql/learn-sql-server/robyn-pages-sql-server-cursor-workbench/

    It is dead fast.
View as RSS news feed in XML