Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Column and Row Total Expand / Collapse
Posted Monday, January 18, 2010 6:45 AM


Group: General Forum Members
Last Login: Wednesday, June 6, 2012 2:50 AM
Points: 19, Visits: 47
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.

Post #849124
Posted Monday, January 18, 2010 7:07 AM



Group: General Forum Members
Last Login: Saturday, December 3, 2016 5:18 AM
Points: 45,619, Visits: 44,147
Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

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

Post #849139
Posted Monday, January 18, 2010 1:08 PM



Group: General Forum Members
Last Login: Wednesday, February 10, 2016 11:50 AM
Points: 6,897, Visits: 13,559
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...)

A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #849351
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse