Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.databases.ms-sqlserver    |    Notorious Rube Goldberg contraption    |    19,505 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 17,980 of 19,505    |
|    tshad to All    |
|    Total columns and rows    |
|    26 Oct 10 12:36:20    |
   
   From: tfs@dslextreme.com   
      
   I am doing a pivot where the sql is dynamic as I don't know the column names   
   until done.   
      
   But I am trying to get totals for my rows and totals for my columns (the   
   pivoted columns).   
      
   How would I do that if I have the following:   
      
   I am using:   
      
   SET @sql = '   
   select * from #tfs   
   PIVOT   
   (   
    SUM(Number)   
    for retailer in('+@strList+')   
   ) as pvt   
   '   
      
   To get.   
      
   select * from #tfs   
   PIVOT   
   (   
    SUM(Number)   
    for retailer in([Sears], [CompUSA], [Lowes], [None], [K-Mart])   
   ) as pvt   
      
   Thanks,   
      
   Tom   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca