How do I do a running total in a SELECT statement?

  • I've got a time(7) column in my database, that I'd like to perform a running total on, in a computed column, when I run a query against that table. I don't know how to do that in SQL, or if it is even possible.

    Rod

  • Hi Rod

    Running Totals are certainly possible in SQL.

    There is an excellent article at:

    http://www.sqlservercentral.com/articles/T-SQL/68467/ by Jeff Moden

    I would also strongly suggest that you read this:

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    If you are prepared to provide the required CREATE/INSERT statements as the article above recommends and also your desired results you will find that you will receive quick and tested responses from this forum....all of whom give their time freely.

    It would also be useful to know the "scale" of your problem...ie how many rows

    Kind regards

    Graham

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Thank you very much for the links! The number of rows returned are pretty small; maybe a dozen at most. Normally 5 rows.

    Rod

Viewing 3 posts - 1 through 2 (of 2 total)

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