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,985 of 19,505    |
|    tshad to tshad    |
|    Re: Total columns and rows    |
|    26 Oct 10 15:32:16    |
   
   From: tfs@dslextreme.com   
      
   I finally got this to work using the following:   
      
   SET @sql = '   
   select * from #tfs   
   PIVOT   
   (   
    SUM(Number)   
    for retailer in('+@strList+')   
   ) as pvt   
   UNION   
   select 'Grand Total', from #tfs   
   PIVOT   
   (   
    SUM(Number)   
    for retailer in('+@strList+')   
   ) as pvt   
   '   
   The problem is that the 2nd Select after the UNION is being put at the 3rd   
   row instead of at the bottom???   
      
   How do you get it to put the results of the 2nd select after the 1st   
   select???   
      
   Thanks,   
      
   Tom   
      
   "tshad"
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca