title: Write an SQL Query to calculate total purchase amount of each customer
body: <p>I'm trying to calculate the total purchase amount of each customer from the database available online on <a href="https://www.w3schools.com/sql/trysql.asp?filename=trysql_op_in" rel="nofollow noreferrer">W3 Schools</a></p>
  <p>The tables I'm using are:</p>
  <blockquote>
  <p>Customers</p>
  <p>Orders</p>
  <p>Products</p>
  <p>OrderDetails</p>
  </blockquote>
  <p>My current query gives me the product wise purchase amount for the customer. What I need is the total purchase amount.</p>
  <pre><code>SELECT c.CustomerID,o.OrderID,(ord.Quantity*p.Price) as 
  Total_Amount
  from Customers c inner join Orders o
  inner join Products p
  inner join OrderDetails ord
  on c.CustomerID = o.CustomerID
  and o.OrderID = ord.OrderID
  and ord.ProductID = p.ProductID;
  </code></pre>
  <blockquote>
  <p><strong>My Output:</strong></p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/kgZ1O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kgZ1O.png" alt="Output" /></a></p>
  <p>I need the sum for the values with the same order id and customer id.</p>
  <p>I tried out group-by and sum but it gives me the overall sum of all the products.</p>