title: How to calculate Grand Totals for invoices with multiple purchases in SQL
body: <p>One of the queries for the assignment I am working on is: "Create a query that calculates the total dollar amount of the purchase and shows the customer id and customer name related to that purchase for each order." I created all the tables necessary for the assignment and completed the first 2 queries no problem. But for this third query I was able to calculate the total of each individual PURCHASE but couldn't get it to give me the total of each of the purchases in the ORDER cause when I used a <code>SUM</code> in front of the price calculation it gave me "not a single-group group function" or when I tried to use <code>GROUP BY</code> it said "not a <code>GROUP BY</code> function".</p>
  
  <p>I used this Code:  </p>
  
  <pre><code>SELECT (i.ItemPrice * t.ItemQty) AS Purchase_Total, o.OrderID, c.CustomerID, c.CustomerName
  FROM pillmanb1_Orders o, pillmanb1_Items i, pillmanb1_Transactions t, pillmanb1_Customers c
  WHERE o.CustomerID = c.CustomerID
  AND i.ItemID = t.ItemID
  AND o.OrderID = t.OrderID;
  </code></pre>
  
  <p>To get this answer:</p>
  
  <p><a href="http://i.stack.imgur.com/WQN04.png" rel="nofollow">First Attempt</a> </p>
  
  <p>But what I really need is this:</p>
  
  <p><a href="http://i.stack.imgur.com/80ZoI.png" rel="nofollow">Correct Prediction</a></p>
  
  <p>I know this one might be easy for you guys but I appreciate the help!!
  Thanks!!</p>