StatisticsRetainedUserMapper.xml
3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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>