>  기사  >  데이터 베이스  >  mysql统计留存率

mysql统计留存率

WBOY
WBOY원래의
2016-06-07 15:09:571963검색

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 Sql代码 begin declare i int; declare numareaId int(10); declare currentareaId int(10); SELECT COUNT(areaId),MIN(areaId) INTO @a,@b FROM option_area_info; SET numareaId=@a; SET currentar

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  Sql代码

  begin

  declare i int;

  declare numareaId int(10);

  declare currentareaId int(10);

  SELECT COUNT(areaId),MIN(areaId) INTO @a,@b FROM option_area_info;

  SET numareaId=@a;

  SET currentareaId=@b;

  loop1:WHILE numareaId>0 DO

  SET @AID = currentareaId;

  SET i=1;

  while i

  if exists(select * from statistics_player_l where createTime>=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set oneDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 1 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set twoDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 2 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set threeDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 3 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set fourDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 4 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set fiveDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 5 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set sixDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 6 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  update statistics_player_l set sevenDayPlayer=(select ((select count(distinct playerId) from log_login where registerTime=date_sub(curdate(),interval i day) and loginTime>=date_add(date_sub(curdate(),interval i day),interval 7 day) and loginTime=date_sub(curdate(),interval i day) and createTime

  end if;

  SET i=i+1;

  end while;

  SET numareaId=numareaId-1;

  SET currentareaId=currentareaId+1;

  END WHILE loop1;

  end

mysql统计留存率

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.