StatisticsRetainedUserMapper.xml 3.79 KB
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bjivt.entity.showtime.StatisticsRetainedUser">

   <!-- 统计注册人数 总数变化情况-->  
  <select id="getRetainedUserByMap"  parameterType="java.util.Map" resultType="com.bjivt.entity.vo.StatisticsDecResult">
	 select '次日' as time,counts_next/counts_curr*100 as counts from(
	(select count(*) counts_next from db_showtime_log.tbl_login_log u 
	 where date_format(u.login_time,'%Y-%m-%d') = date_add(str_to_date(#{startTime},'%Y-%m-%d'),interval 1 day)
	       and u.user_id in (select u.user_id from db_showtime_log.tbl_login_log tl 
	 where date_format(tl.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d'))) as counts_next,
	 (select count(*) counts_curr from db_showtime_log.tbl_login_log u 
	 where date_format(u.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d')) as counts_curr)
	  Union
	 select '第三天' as time,counts_next/counts_curr*100 as counts from(
	(select count(*) counts_next from db_showtime_log.tbl_login_log u 
	 where 
	 <![CDATA[date_format(u.login_time,'%Y-%m-%d') > str_to_date(#{startTime},'%Y-%m-%d')
	 and date_format(u.login_time,'%Y-%m-%d') <= date_add(str_to_date(#{startTime},'%Y-%m-%d'),interval 3 day)]]>
	       and u.user_id in (select u.user_id from db_showtime_log.tbl_login_log tl 
	 where date_format(tl.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d'))) as counts_next,
	 (select count(*) counts_curr from db_showtime_log.tbl_login_log u 
	 where date_format(u.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d')) as counts_curr)
	  Union
	 select '第七天' as time,counts_next/counts_curr*100 as counts from(
	(select count(*) counts_next from db_showtime_log.tbl_login_log u 
	 where 
	 <![CDATA[ date_format(u.login_time,'%Y-%m-%d') > str_to_date(#{startTime},'%Y-%m-%d')
	 and date_format(u.login_time,'%Y-%m-%d') <= date_add(str_to_date(#{startTime},'%Y-%m-%d'),interval 7 day)]]>
	       and u.user_id in (select u.user_id from db_showtime_log.tbl_login_log tl 
	 where date_format(tl.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d'))) as counts_next,
	 (select count(*) counts_curr from db_showtime_log.tbl_login_log u 
	 where date_format(u.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d')) as counts_curr)
	  Union
	 select '第14天' as time,counts_next/counts_curr*100 as counts   from(
	(select count(*) counts_next from db_showtime_log.tbl_login_log u 
	 where 
	 <![CDATA[ date_format(u.login_time,'%Y-%m-%d') > str_to_date(#{startTime},'%Y-%m-%d')
	 and date_format(u.login_time,'%Y-%m-%d') <= date_add(str_to_date(#{startTime},'%Y-%m-%d'),interval 14 day)]]>
	       and u.user_id in (select u.user_id from db_showtime_log.tbl_login_log tl 
	 where date_format(tl.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d'))) as counts_next,
	 (select count(*) counts_curr from db_showtime_log.tbl_login_log u 
	 where date_format(u.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d')) as counts_curr)
	  Union
	 select '第30天' as time,counts_next/counts_curr*100 as counts from(
	(select count(*) counts_next from db_showtime_log.tbl_login_log u 
	 where 
	 <![CDATA[ date_format(u.login_time,'%Y-%m-%d') > str_to_date(#{startTime},'%Y-%m-%d')
	 and date_format(u.login_time,'%Y-%m-%d') <= date_add(str_to_date(#{startTime},'%Y-%m-%d'),interval 30 day)]]>
	       and u.user_id in (select u.user_id from db_showtime_log.tbl_login_log tl 
	 where date_format(tl.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d'))) as counts_next,
	 (select count(*) counts_curr from db_showtime_log.tbl_login_log u 
	 where date_format(u.create_time,'%Y-%m-%d') = str_to_date(#{startTime},'%Y-%m-%d')) as counts_curr)
 
 </select>  
</mapper>