Re: Help with query
From: Rohtash Kapoor (rohtash_nospam_at_sqlmantra.com)
Date: 03/10/04
- Next message: Newbie: "Re: Help with query"
- Previous message: Newbie: "Re: Using SQL to find PKs for each table"
- In reply to: Newbie: "Help with query"
- Next in thread: Newbie: "Re: Help with query"
- Reply: Newbie: "Re: Help with query"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 10 Mar 2004 07:59:33 -0800
UPDATE SO
SET TotalQty =
(SELECT SUM(OrderQty) FROM SODet
WHERE (SalesOrder = '12345') AND (Line = '1')
GROUP BY SalesOrder)
WHERE SalesOrder = '12345'
--- Rohtash Kapoor http://www.sqlmantra.com "Newbie" <noidea@nospam.com> wrote in message news:ulmBmOrBEHA.1964@TK2MSFTNGP11.phx.gbl... > Hi, > > I want to be able to update a field in one table with the sum of a field > from another table but i don't know how to link the two > > Here is what I have so far to get the TotalQty > *****TOTAL QRY***** > SELECT SalesOrder,SUM(OrderQty) AS TotalQty > FROM SODet > WHERE (SalesOrder = '12345') AND (Line = '1') > GROUP BY SalesOrder > > I then want to use the result of the above to update the SO table where the > SO.SalesOrder = SODet.SalesOrder > > i.e Result of TOTAL QRY = 30000 > therefore SO.Total = 30000 > > How can I do this? > Thanks > >
- Next message: Newbie: "Re: Help with query"
- Previous message: Newbie: "Re: Using SQL to find PKs for each table"
- In reply to: Newbie: "Help with query"
- Next in thread: Newbie: "Re: Help with query"
- Reply: Newbie: "Re: Help with query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|