新人学SQL 现在条件是当数量大于1000时 打折扣 95%,当数量大于2000时 打折扣 90%,当数量大于5000时 打折扣 85%.
CREATE TRIGGER lll on seorderEntry
for update
As
IF UPDATE(FQty) AND EXISTS(SELECT * from inserted where FQty>=1000 or FQty<2000)
begin
update seorderEntry set FTaxRate = 95 where FQty>=1000 or FQty<2000
rollback
end
IF UPDATE(FQty) AND EXISTS(SELECT * from inserted where FQty>=2000 or FQty<5000)
begin
update seorderEntry set FTaxRate = 90 where FQty>=2000 or FQty<5000
rollback
end
IF UPDATE(FQty) AND EXISTS(SELECT * from inserted where FQty>5000 )
begin
update seorderEntry set FTaxRate = 85 where FQty>5000
rollback
end
求讲解
CREATE TRIGGER lll on seorderEntry
for update
As
IF UPDATE(FQty) AND EXISTS(SELECT * from inserted where FQty>=1000 or FQty<2000)
begin
update seorderEntry set FTaxRate = 95 where FQty>=1000 or FQty<2000
rollback
end
IF UPDATE(FQty) AND EXISTS(SELECT * from inserted where FQty>=2000 or FQty<5000)
begin
update seorderEntry set FTaxRate = 90 where FQty>=2000 or FQty<5000
rollback
end
IF UPDATE(FQty) AND EXISTS(SELECT * from inserted where FQty>5000 )
begin
update seorderEntry set FTaxRate = 85 where FQty>5000
rollback
end
求讲解