,为了数据库程序员的薪水,SQL高手请进,

来源:百度知道 编辑:UC知道 时间:2024/06/15 15:34:12
创建一个存储过程,对10个程序员的工资进行分析,开始分别是:2000,1800,5000,6000,3500,2000,1800,5000,6000,3500,如果有5个人薪水不到6000元,给所有人加薪,每次加100,再进行分析,直到有一半以上的人大于6000为止,存储过程执行完后,最终加了多少钱?

请务必要用SQL Server 语句格式写!
多谢!

思路是这个了
你自己打包成存储过程好了

/*
drop table t1

select * from t1
*/

go
create table t1(autoID int identity(1,1),money1 int)
go
insert into t1(money1) values(2000)
go
insert into t1(money1) values(1800)
go
insert into t1(money1) values(5000)
go
insert into t1(money1) values(6000)
go
insert into t1(money1) values(3500)
go
insert into t1(money1) values(2000)
go
insert into t1(money1) values(1800)
go
insert into t1(money1) values(5000)
go
insert into t1(money1) values(6000)
go
insert into t1(money1) values(3500)
go
select sum(money1) as '原来总工资' from t1
declare @i int,@count int,@countEnd int,@money int
set @i=1
set @count=0
set @countEnd=0
while not @i>10
begin
set @money = (select money1 from t1 where autoID = @i)
if @money < 6000
begin
set @count= @count+1
if @c