Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GROUP BY in Update Statement 1

Status
Not open for further replies.

ben1234zz

MIS
May 12, 2008
71
GB
Hi

I am struggleing to create this update statement with a select/group by clause:

UPDATE PP SET PP.Ex = SUM(LPP.Ex)
FROM SM_Prod_Pricing PP
INNER JOIN SM_NFW_Bundle_Pricing_Link BP
ON PP.ID = BP.Pricing_ID
INNER JOIN SM_Prod_Pricing LPP
ON BP.Linked_Pricing_ID = LPP.ID
GROUP BY BP.Pricing_ID

It works fine with the equivelent Select statement but the group by causes an error in the update.

Any assistance would be much appreciated.

Thanks
B
 
The following may not be absolutely correct, but at least will point youon the right direction.

UPDATE PP SET PP.Ex = sum_Ex
FROM SM_Prod_Pricing PP
INNER JOIN (select pricing_id, sum(lpp.ex) as sum_ex
from SM_NFW_Bundle_Pricing_Link BP
INNER JOIN SM_Prod_Pricing LPP
ON BP.Linked_Pricing_ID = LPP.ID
GROUP BY BP.Pricing_ID ) lpp
ON pP.id = LPP.Pricing_ID

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top