您的位置:首页 > 其它

考虑同时参加工作的情况

2009-05-01 13:10 260 查看
declare aaaa scroll cursor
for select 姓名,工作时间 from 教师 order by 工作时间
open aaaa
declare @name varchar(50),@worktime datetime
fetch next from aaaa into @name,@worktime
declare @i int,@worktime1 datetime,@j int
set @i=1
set @j=0
set @worktime1=@worktime
while(@@fetch_status=0)
begin
if(@worktime1=@worktime)
begin
update 教师 set 参加工作先后=@i where current of aaaa
fetch next from aaaa into @name,@worktime
set @j=@j+1
end
else
begin
set @i=@i+@j
update 教师 set 参加工作先后=@i where current of aaaa
set @worktime1=@worktime
fetch next from aaaa into @name,@worktime
set @j=1
end
end
close aaaa
deallocate aaaa
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐