Column and Row Total

  • I need to calculate row and column totals. I am selecting the report from one view. In that view days are across those dates are getting dynamically.

    This view will get updated every day and every day new column(current date as new column) will be added to the report

    Please some one suggest me to add the row and column totals for that view.

    Thanks

  • Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

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

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I'd talk to the folks that are responsible for the script that adds the column each day to give me another column [row_total] that would add all previous columns. If they do it using DynamicCrossTab it'll be an easy task for them to do. 😉

    To get the column totals use sum() or, if needed together with the row results, look into WITH ROLLUP operator.

    If you need more info than that, please read the first link in my signature (it'll link you to the same article Gail has been pointing at...)



    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]

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

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