title: subquery returning more than 1 value, error Msg 512
body: <p>SQL Server 2012. </p>
  
  <p>I am not sure how to get my subquery to work. It returns more than 1 value which is not permitted. I want a sum of a quantity per customerID. The <code>customerID</code> exists in <code>tblOrder</code>, the <code>QuantityOrdered</code> in <code>LineItem</code> table.</p>
  
  <pre><code>SELECT 
      CustomerID, ProductID, 
      SUM(QuantityOrdered) AS QuantitySum,
      (SELECT (SUM(QuantityOrdered)) 
       FROM LineItem
       INNER JOIN tblOrder ON tblOrder.OrderID = LineItem.OrderID 
       GROUP BY CustomerID) as PRACTICE
  FROM 
      tblOrder
  INNER JOIN 
      LineItem LI ON tblOrder.OrderID = LI.OrderID
  WHERE 
      OrderDate BETWEEN '2016-01-31' AND '2016-03-01'
  GROUP BY 
      ProductID, CustomerID
  ORDER BY 
      CustomerID
  </code></pre>