学历改变命运
24小时客服:4008135555/010-82335555
当前位置:首页> 历年试题 > 北大“数据库原理”上机实践题目总结(12)

北大“数据库原理”上机实践题目总结(12)

2007年07月18日    来源:   字体:   打印
查分预约

  declare @WID char(5)

  declare @RID char(5)

  set @MAX_Earning = -65535

  set @NumID = 'XXX'

  set @MAX_NumID = 'XXX'

  declare CurNum cursor for

  select NID

  from Numbers

  open CurNum

  fetch from CurNum into @NumID

  while @@fetch_status = 0

  begin

  set @Earning = 0

  declare CurChip cursor for

  select RRecord.HID as WinID,CRecord.HID as RID

  from RRecord,CRecord

  where RRecord.SerNum = CRecord.SerNum and CRecord.NID = @NumID

  open CurChip

  fetch from CurChip into @WID,@RID

  while @@fetch_status = 0

  begin

  if @WID = @RID

  set @Earning = @Earning + 8

  else

  set @Earning = @Earning - 2

  fetch from CurChip into @WID,@RID

  end

  close CurChip

  DEALLOCATE CurChip

  if @Earning > @MAX_Earning

  begin

  set @MAX_NumID = @NumID

  set @MAX_Earning = @Earning

  end

  print @NumID + CONVERT(Varchar(20),@Earning)

  fetch from CurNum into @NumID

  end

  close CurNum

  DEALLOCATE CurNum

  print '赚钱更多的会员'

  print @MAX_NumID + CONVERT(Varchar(20),@MAX_Earning)

  /*=======================================================*/

  /*马场主赚了多少钱*/

  declare @Cash int

  set @Cash = 0

  declare CurTol cursor for

  select RRecord.HID as WinID,CRecord.HID as RID

  from RRecord,CRecord

  where RRecord.SerNum = CRecord.SerNum

  open CurTol

  fetch from CurTol into @WID,@RID

  while @@fetch_status = 0

  begin

  if @WID = @RID

  set @Cash = @Cash - 8

  else

  set @Cash = @Cash + 2

  fetch from CurTol into @WID,@RID

  end

  close CurTol

  DEALLOCATE CurTol

  print '场主赚了' + CONVERT( VARCHAR(10),@CASH) + '钱'

  drop table CRecord

  drop table RRecord

  drop table Numbers

  drop table Horses

关注添加

扫码添加学习顾问

了解考试计划,进行学习规划
备战考试,获取试题及资料

扫码下载APP

海量历年试题、备考资料
免费下载领取

扫码进入微信小程序

每日练题巩固、考前模拟实战
免费体验自考365海量试题

免费题库

新人有礼
关闭