I am trying to update a numeric field in a table. It is a quantity on hand(Decimal) column. Basically I would have:
An indexed field - itemid
A location_id
The quantity field.
This query works:
UPDATE tablename
set [quantity]
= (SELECT [quantity] as qoh from inv_loc where [itemid]= 'value' and location_id=value) + (SELECT [quantity] as qoh from inv_loc where [itemid]= 'value' and location_id=other_value)
where itemid=itemid
and location_id=value)
What I want to do is to take all the quantities that are tied to one location_id and add those values to the other quantity for the other location_id. Pretty easy to do with one value but I am not sure how best to do it with multiple values.
Thanks for your help.
An indexed field - itemid
A location_id
The quantity field.
This query works:
UPDATE tablename
set [quantity]
= (SELECT [quantity] as qoh from inv_loc where [itemid]= 'value' and location_id=value) + (SELECT [quantity] as qoh from inv_loc where [itemid]= 'value' and location_id=other_value)
where itemid=itemid
and location_id=value)
What I want to do is to take all the quantities that are tied to one location_id and add those values to the other quantity for the other location_id. Pretty easy to do with one value but I am not sure how best to do it with multiple values.
Thanks for your help.