title: SQL Update Query with aggregate function
body: <p>I have 2 tables like:</p>
  
  <pre><code>CREATE TABLE [dbo].[Inventory](
  [ID] [int] IDENTITY(1,1) NOT NULL
  [SerialNo] [nvarchar](50) NOT NULL,
  [Quantity] [decimal](12, 3) NULL)
  
  CREATE TABLE [dbo].[InventoryDetails](
  [ID] [int] IDENTITY(1,1) NOT NULL,
  [InventoryID] [int] NOT NULL,
  [ProductID] [int] NOT NULL,
  [Quantity] [decimal](10, 3) NOT NULL)
  </code></pre>
  
  <p>I wanna execute query like:</p>
  
  <pre><code>Update I set Quantity=Sum(ID.Quantity)
  from Inventory I
  Inner Join inserted ID on I.ID=ID.InventoryID
  </code></pre>
  
  <p>SQL Servers gives this error: 
  <code>An aggregate may not appear in the set list of an UPDATE statement.</code></p>
  
  <p>what is the true way to do this? Do I Need Group By Clause?</p>