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