title: MS SQL rollup percentage column
body: <p>I am using rollup to sum a table containing fields <code>company</code>, <code>sales</code>, <code>cost</code> and <code>margin</code>. This gives me the summarized columns, but I need to show a summarized percentage of the margin as a percentage of sales for each company summary.</p>
  
  <p>This is my current statement:</p>
  
  <pre><code>SELECT coalesce(CAST(Company AS VARCHAR(30)), 'Grand Total:') AS Company,
         SUM(Sales)                                             AS 'TOTSALES',
         SUM(CostVal)                                           AS 'TOTCOST',
         SUM(MarginVal)                                         AS 'TOTMAR'
  FROM   DailySalesSum
  GROUP  BY Company WITH ROLLUP;  
  </code></pre>