存在以下数据表tblProducts
Create table tblProducts
(
productID int primary key, -- 商品编号
productName char(10) not null, -- 商品名称
price decimal(5,1) – 单价
)
Insert into tblProducts values(1,’apple’,5.5),(2,’orange’,3.5),(3,’pear’,6),(4,’chewberry’,11)
当商品价格为5~6 元,涨价10%
当商品价格大于10元,涨价5%
其余价格不变。
sql语句就可以搞定啊,如果用游标得写存储过程,大致就是循环查询数据,根据条件修改数据
update tblProducts a set price =price *(1+(case
when a.price between 5 and 6 then 0.1
when a.price >10 then 0.05
else 0
end))