Actualizar statement usando Unirse y Agrupar por

He escrito la siguiente statement de actualización, pero muestra el error, como "syntax incorrecta cerca de la palabra key 'GRUPO'".

UPDATE J SET J.StatusID = CASE WHEN SUM(DUV.VendorDUQuantity) = SUM(RD.InvoiceQuantity) THEN 1 ELSE J.StatusID END FROM PLN_DU_Vendor DUV INNER JOIN ENG_Release R ON R.ReleaseID = DUV.ReleaseID INNER JOIN ENG_DU_Header H ON H.ReleaseID = R.ReleaseID AND DUV.DUID = H.DUID INNER JOIN MKT_JobOrder J ON J.JobOrderID = R.JobOrderID INNER JOIN MKT_CustomerOrder CO ON CO.OrderID = J.OrderID LEFT JOIN PMT_RFDHeader RH ON RH.JobOrderID = J.JobOrderID LEFT JOIN PMT_RFDDetail RD ON RD.RFDID = RH.RFDID AND RD.DUID = DUV.DUID WHERE CO.OrderID = 100 GROUP BY J.JobOrderID 

En lugar de actualizar, Select funciona perfectamente para la consulta anterior. Cuál sería el problema y Cómo escribir la consulta en function de las cláusulas Join y Group By.

Puede intentar ubicar el grupo dentro de una subconsulta y, a continuación, unir mediante el "ID de Orden de trabajo", de esta manera:

 UPDATE J SET J.StatusID = A.statusId FROM MKT_JobOrder J INNER JOIN ( SELECT J.JobOrderID ,CASE WHEN SUM(DUV.VendorDUQuantity) = SUM(RD.InvoiceQuantity) THEN 1 ELSE J.StatusID END AS statusId PLN_DU_Vendor DUV INNER JOIN ENG_Release R ON R.ReleaseID = DUV.ReleaseID INNER JOIN ENG_DU_Header H ON H.ReleaseID = R.ReleaseID AND DUV.DUID = H.DUID INNER JOIN MKT_JobOrder J ON J.JobOrderID = R.JobOrderID INNER JOIN MKT_CustomerOrder CO ON CO.OrderID = J.OrderID LEFT JOIN PMT_RFDHeader RH ON RH.JobOrderID = J.JobOrderID LEFT JOIN PMT_RFDDetail RD ON RD.RFDID = RH.RFDID AND RD.DUID = DUV.DUID WHERE CO.OrderID = 100 GROUP BY J.JobOrderID ,J.StatusID ) A ON J.JobOrderID = A.JobOrderID 

Sub consulta del usuario en su lugar para realizar esta operación

 UPDATE J SET StatusID = x.Status FROM (select CASE WHEN SUM(DUV.VendorDUQuantity) = SUM(RD.InvoiceQuantity) THEN 1 ELSE J.StatusID END as Status JobOrderID FROM PLN_DU_Vendor DUV INNER JOIN ENG_Release R ON R.ReleaseID = DUV.ReleaseID INNER JOIN ENG_DU_Header H ON H.ReleaseID = R.ReleaseID AND DUV.DUID = H.DUID INNER JOIN MKT_JobOrder J ON J.JobOrderID = R.JobOrderID INNER JOIN MKT_CustomerOrder CO ON CO.OrderID = J.OrderID LEFT JOIN PMT_RFDHeader RH ON RH.JobOrderID = J.JobOrderID LEFT JOIN PMT_RFDDetail RD ON RD.RFDID = RH.RFDID AND RD.DUID = DUV.DUID WHERE CO.OrderID = 100 GROUP BY J.JobOrderID) X INNER JOIN MKT_JobOrder J On x.JobOrderID = J.JobOrderID