create table productprice
(Productcode varchar(2),
pricecategory char(1),
price int)
insert into productprice values ('a1','a',10),('a1','b' ,9),('a2','a',7),('a2','b',6),('a3','a' ,6),('a3','b',5),('a4','a',5),('a4','b',4),('a5','a',11),('a5','b', 10)
update a
set price=b.price
from productprice a
inner join productprice b
on a.Productcode=b.Productcode
and a.pricecategory='b'
and b.pricecategory='a'
I assume,Company have product a1, which sell to 2 customer, a and b user already change product price a1 for customer a, from 9 to 10
now they want product price a1 for customer b also change as customer b
上面的代码设于假设的基础上,而没有经过正确的测试..请自己测试及更改
PL/SQL should very easy ? how ?
|