title: How to SUM from another table in SQL in one view?
body: <p>I have 2 tables
  Maintable
  and
  Secondtable</p>
  
  <p>In the Second Table is a Column Maintable_ID and Price.</p>
  
  <p>I have bulided up a view in Workbench like this:</p>
  
  <pre><code>CREATE VIEW test AS 
  SELECT Maintable.ID as ID,
         Maintable.Name as Name,
         Maintable.Date as Date,
         Secondtable.Price as Price,
  From maintable
  
  LEFT JOIN secondtable
  ON Maintable.ID=Secondtable.Maintable_ID
  </code></pre>
  
  <p>I have thought about to make something like:</p>
  
  <p><code>SUM(Price) as GPrice FROM Secondtable WHERE Maintable.ID=Secondtable.Maintable_ID</code></p>
  
  <p>How Can I find out the total price for all items in the Secondtable where Secondtable.Maintable_ID= Maintable.ID</p>
  
  <p>Thank you for your help.</p>