cursor


CREATE procedure sp_headshotrate_Hitrate_vip
as
declare @headshot numeric(10,2), @hit numeric(10,2),@dv_user_id numeric,@kills numeric(10,2),@shots numeric(10,2),@headshotrate numeric(10,2),@hitrate numeric(10,2)
begin
 Declare cur_user cursor  for
 select sum(headshots) as headshot,sum(kills) as kills,dv_user_id from fight_week_weapon  where weaponname<>'grenade'   group by dv_user_id
 OPEN cur_user
 FETCH NEXT FROM cur_user INTO @headshot,@kills,@dv_user_id
 WHILE @@FETCH_STATUS = 0
 BEGIN
  if (@kills<1)
   set @headshotrate=0
  else
   set @headshotrate=convert(numeric(10,2),@headshot)/convert(numeric(10,2),@kills) * 100  

  update [user] set vip_headshotrate=@headshotrate where dv_user_id=@dv_user_id

  FETCH NEXT FROM cur_user INTO @headshot,@kills,@dv_user_id
 END
 close cur_user
 deallocate cur_user

 Declare cur_user cursor  for
 select sum(hits) as hit,sum(shots) as shots,dv_user_id from fight_week_weapon  where weaponname<>'knife'  group by dv_user_id
 OPEN cur_user
 FETCH NEXT FROM cur_user INTO @hit,@shots,@dv_user_id
 WHILE @@FETCH_STATUS = 0
 BEGIN
  if (@shots<1)
   set @hitrate=0
  else
   set @hitrate=convert(numeric(10,2),@hit)/convert(numeric(10,2),@shots) * 100 

  update [user] set vip_hitrate=@hitrate where dv_user_id=@dv_user_id

  FETCH NEXT FROM cur_user  INTO @hit,@shots,@dv_user_id
 END
 close cur_user
 deallocate cur_user
end

GO
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值