![]() |
#2
purana2007-11-29 20:29
|

declare @xx char(20),@yy char(20) ,@zz char(20)
declare zz cursor for
select 员工号,姓名,缺勤名称 from JBQK a, QQLX b where a.缺勤类型 = b.缺勤类型 and a.缺勤天数 = 1
print '缺勤天数为1天的'
open zz
fetch next from zz into @xx,@yy,@zz
while @@fetch_status = 0
begin
fetch next from zz into @xx,@yy,@zz
print '员工号'++' '+'姓名'+' '+'缺勤名称'
print @xx +@yy + @zz
end
close zz
declare yy cursor for
select 员工号,姓名,缺勤名称 from JBQK a, QQLX b where a.缺勤类型 = b.缺勤类型 and a.缺勤天数 = 2
print '---------------------'
print '缺勤天数为2天的'
open yy
fetch next from yy into @xx,@yy,@zz
while @@fetch_status = 0
begin
fetch next from yy into @xx,@yy,@zz
print '员工号'++' '+'姓名'+' '+'缺勤名称'
print @xx +@yy + @zz
end
close yy
结果查出来两个结果一样的declare zz cursor for
select 员工号,姓名,缺勤名称 from JBQK a, QQLX b where a.缺勤类型 = b.缺勤类型 and a.缺勤天数 = 1
print '缺勤天数为1天的'
open zz
fetch next from zz into @xx,@yy,@zz
while @@fetch_status = 0
begin
fetch next from zz into @xx,@yy,@zz
print '员工号'++' '+'姓名'+' '+'缺勤名称'
print @xx +@yy + @zz
end
close zz
declare yy cursor for
select 员工号,姓名,缺勤名称 from JBQK a, QQLX b where a.缺勤类型 = b.缺勤类型 and a.缺勤天数 = 2
print '---------------------'
print '缺勤天数为2天的'
open yy
fetch next from yy into @xx,@yy,@zz
while @@fetch_status = 0
begin
fetch next from yy into @xx,@yy,@zz
print '员工号'++' '+'姓名'+' '+'缺勤名称'
print @xx +@yy + @zz
end
close yy
员工号 姓名 缺勤名称
5 邓刚 病假
---------------------
缺勤天数为2天的
员工号 姓名 缺勤名称
4 张晓华 事假
员工号 姓名 缺勤名称
4 张晓华 事假
5 邓刚 病假
---------------------
缺勤天数为2天的
员工号 姓名 缺勤名称
4 张晓华 事假
员工号 姓名 缺勤名称
4 张晓华 事假