日期:2014-05-18 浏览次数:20514 次
update tb set Speet=case left(TrianName,1) when 't' then Speet*(1.25) when 'z' then Speet*(1.25) else Speet end
------解决方案--------------------
update tb set Speet=(case when substring(TrianName,1,1)='K' then Speet
when substring(TrianName,1,1)='T' then (Speet+Speet*0.2)
when substring(TrianName,1,1)='Z' then (Speet+Speet*0.25)
end )
------解决方案--------------------
可以用存储过程判断,可参考语句:
declare @Name varchar(100)
select id from dbo.[Table1] where TrianName=@Name
if @Name='K'
update dbo.[Table1] set Speet='' where TrianName=@Name
else if @Name='Z'
update dbo.[Table1] set Speet='' where TrianName=@Name
------解决方案--------------------
update table1 set Speet=case left(TrianName,1) when 't' then Speet*(1.25) when 'z' then Speet*(1.25) else Speet end