title: SELECT Aggregate and UPDATE - SQL Server
body: <p>SQL Server beginner here. I am having some trouble on a SELECT/UPDATE statement. I have a table with an order number column and a line number column. The select statement below returns the values I want. I would like to take the result and insert that number into a column on the same table where the order number matches. Am I over thinking this? Or maybe under thinking the complexity? :)</p>
  
  <pre><code>    SELECT
      ORDNUM, COUNT(LINNUM) AS 'CountLines'
      FROM [TableName]
      WHERE STS = '3' AND DUEQTY &lt; ONHAND AND STYPE = 'CU'
      GROUP BY ORDNUM
  
      UPDATE [TableName]
      SET LNCNT = 'CountLines'
      WHERE ORDNUM = ORDNUM
  </code></pre>
  
  <p>Thank you in advance. 
  Ben</p>
  
  <p><strong>UPDATE: I used Andomars solution below and it worked great. Thank you all for the assistance.</strong> </p>