用存储过程实现:一个公司为员工加薪,为工资在3000元以下的每次加100元,直到公司有一半的人工资在3000元以上,停止加薪,计算一共有多少人次加了薪?公司一共用去多少钱为员工加薪?
CREATE PROCEDURE addgongzi AS
declare @lenth int
declare @num int
set @lenth=select count(*) from gongz where price<3000
set @num=select count(*)/ 2 from gongzi
while(@lenth<@num)
begin
update gongzi set price =price+100 where price<3000
set @lenth=select count(*) from gongz where price<3000
set @num=select count(*)/2 from gongzi
@num+=@lenth
end
这是错的 哪位高手指教一下
CREATE PROCEDURE addgongzi AS
declare @lenth int
declare @num int
set @lenth=select count(*) from gongz where price<3000
set @num=select count(*)/ 2 from gongzi
while(@lenth<@num)
begin
update gongzi set price =price+100 where price<3000
set @lenth=select count(*) from gongz where price<3000
set @num=select count(*)/2 from gongzi
@num+=@lenth
end
这是错的 哪位高手指教一下
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货