求存储过程
一张工资表,共两个字段,员工编号和月工资字段。现由于物价上涨,公司为了提高员工薪水,将按如下规则对员工工资进行调整:
月工资少于2000元的员工涨20%;
在2001元至3000元之间的员工涨15%;
在3001元至6000元的员工涨10%;
6000元以上的员工上涨工资5%.
要求:用存储过程完成本次工资调整,并计算出通过此次工资上调会给公司每月增加多少成本。
月工资少于2000元的员工涨20%;
在2001元至3000元之间的员工涨15%;
在3001元至6000元的员工涨10%;
6000元以上的员工上涨工资5%.
要求:用存储过程完成本次工资调整,并计算出通过此次工资上调会给公司每月增加多少成本。
作者: jackluangle 发布时间: 2011-06-12
SQL code
select sum(月工资*(case when 月工资<=2000 then 0.2 when 月工资 between 2001 and 3000 then 0.15 when 月工资 between 3001 and 6000 then 0.10 when 月工资>6000 then 0.05 end )) as 增加成本 --更新工资表 update 工资表 set 月工资=月工资*(1+ (case when 月工资<=2000 then 0.2 when 月工资 between 2001 and 3000 then 0.15 when 月工资 between 3001 and 6000 then 0.10 when 月工资>6000 then 0.05 end ) )
作者: maco_wang 发布时间: 2011-06-12
SQL code
create proc procname as begin select sum(月工资*(case when 月工资<=2000 then 0.2 when 月工资 between 2001 and 3000 then 0.15 when 月工资 between 3001 and 6000 then 0.10 when 月工资>6000 then 0.05 end )) as 增加成本 --更新工资表 update 工资表 set 月工资=月工资*(1+ (case when 月工资<=2000 then 0.2 when 月工资 between 2001 and 3000 then 0.15 when 月工资 between 3001 and 6000 then 0.10 when 月工资>6000 then 0.05 end ) ) end
作者: maco_wang 发布时间: 2011-06-12
应该是更新工资表吧
作者: fredrickhu 发布时间: 2011-06-12