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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating multiple rows

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have these 3 tables

angaufgut (Master)
lfdnr
provision

angaufpos (Details)
lfdnr
posprovision

produktion
lfdnr

Now my problem: I want to sum up all angaufpos.posprovision where lfdnr is equal and put it into the angaufgut.provision where the lfdnr is the same, but just these with an existing record with the same lfdnr in table produktion
 
I've renamed the tables so I could work it out ive called ifdnr ID, but try...

UPDATE MATER a
SET provision = (SELECT sum(aa.posprovision)
FROM master aa, detaila da, detailb db
WHERE a.id = aa.id
AND aa.id = da.id
AND da.id = db.id)

This will only work if the produktion table has only distinct ifdnr's. if it contains duplicates then you will need to either preselect the distinct ones in an inline view or you could use an EXIST (if your using Oracle).

What DB is this to run on?
 
its an Oracle 8 database and the lfdnr's are distinct. Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top