title: Insert line into a query result (sum)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5719384/insert-line-into-a-query-result-sum">Insert line into a query result (sum)</a>  </p>
  </blockquote>
  
  
  
  <p>I have a report that shows products that customers have ordered, along with their prices:</p>
  
  <pre><code>CompanyA    Product 7    14.99  
  CompanyA    Product 3    45.95
  CompanyA    Product 4    12.00
  CompanyB    Product 3    45.95
  CompanyC    Product 7    14.99
  CompanyC    Product 3    45.95
  </code></pre>
  
  <p>I'd like to insert a line that sums each company's order, like this:</p>
  
  <pre><code>CompanyA    Product 7    14.99  
  CompanyA    Product 3    45.95
  CompanyA    Product 4    12.00
                 Total:    72.94
  CompanyB    Product 3    45.95
                 Total:    45.95
  CompanyC    Product 7    14.99
  CompanyC    Product 3    45.95
                 Total:    60.94
  </code></pre>
  
  <p>Here's some code that shows the basic structure of the query I have:</p>
  
  <pre><code>SELECT company
     , product
     , price
  FROM companyMaster
  ORDER BY company,
     , product,
     , price;
  </code></pre>
  
  <p>Does anyone know how to do this? I'm writing this in Transact-SQL (Microsoft SQL Server).</p>