title: Update records in table from CTE
body: <p>I have the following CTE that will give me the DocTotal for the entire invoice.</p>
  
  <pre><code> ;WITH CTE_DocTotal
   AS
   (
     SELECT SUM(Sale + VAT) AS DocTotal
     FROM PEDI_InvoiceDetail
     GROUP BY InvoiceNumber
   )
  
  UPDATE PEDI_InvoiceDetail
  SET DocTotal = CTE_DocTotal.DocTotal
  </code></pre>
  
  <p>Now with this result I want to enter into the column the DocTotal value inside PEDI_InvoiceDetail.</p>
  
  <p>I know is not going to work and I know I am missing something, what is it?</p>