当前位置:网站首页>Barbie q! How to analyze the new game app?
Barbie q! How to analyze the new game app?
2022-07-02 00:20:00 【Monkey data analysis】

【 subject 】
In order to monitor the newly listed Games APP Popularity of , Analyze the total number of users through data 、 Average age of users and active users ( Visit for two consecutive days ) The total number and average age of . The following table shows the details of user login information table .

Field explanation :
Login date : Record user login to the game APP Time for
user ID: The unique identification of the user
User age : The user is in APP Age of registration
The following results need to be analyzed :
1. Count the total number of users 、 Average age of users
2. Count active users ( Visit for two consecutive days ) The total number and average age of
【 Their thinking 】
1. Count the total number of users 、 Average age of users
From table 1, you can see that the same user has multiple login records on the same day , If you perform aggregate queries directly, it will cause duplicate data calculation , So you should first follow the user ID The de emphasis of duplicate data is to analyze the total number and average age of users .
SQL Writing a :
select distinct user ID, User age
from User login information table ;SQL Write two :
select user ID, User age
from User login information table
group by user ID;Query results :

The query results are used as temporary tables a, Next, use to calculate the number of users (count function ) And ask the average age of users (avg function )
SQL It is written as follows :
select count( user ID) as Total users ,avg( User age ) as Average age of users
from(
select user ID, User age
from User login information table
group by user ID
) a;Query results :

2. Count active users ( Visit for two consecutive days ) The total number and average age of
Active users : It is positioned as having access for two consecutive days , The vernacular is interpreted as logging in today , Number of users logged in tomorrow . That is, the time interval =1.
If a table involves time intervals , You need to use self connection , That is to join two identical tables . Will table a Understood as the user's login time , Will table b Understood as the user's login time again , By calculating the time difference between login time and login time again , The time difference is equal to 1 That means you are also logged in today , Log in tomorrow ( Log in for two consecutive days )

select
a. Login date as The login time ,
a. user ID,
a. User age ,
b. Login date as Login time again
from
User login information table as a
left join User login information table as b on a. user ID = b. user ID;Query results :

The temporary table after connection is marked as table c, So how to start from the table c Find out the time interval ( Landing time tomorrow - Today's landing time )=1 What about the data? ?
(1) This involves calculating the difference between two dates ,《 monkey Learn from scratch sql》 The corresponding single function mentioned in is timestampdiff. The following figure shows the usage of this function .

SQL Write the following :
select *,timestampdiff(day,c. The login time ,c. Logout time ) as The time interval
From c
group by c. user ID,c. The login time ; Query results :

The query results are used as temporary tables d, use case when Statement selects the time interval =1 The data of , Calculate the total number of active users (count) And the average age of active users (avg)
SQL Write the following :
select count(distinct case when The time interval =1 then user ID else null end ) as Total active users ,
avg( case when The time interval =1 then User age else null end ) as Average age of active users
from d;Put the temporary table d Of SQL Plug in , Final SQL The code is as follows :
select
count(distinct case when The time interval =1 then user ID else null end ) as Total active users ,
avg( case when The time interval =1 then User age else null end ) as Average age of active users
from
(
select *,timestampdiff(day,c. The login time ,c. Login time again ) as The time interval
from
(
select
a. Login date as The login time ,
a. user ID,
a. User age ,
b. Login date as Login time again
from User login information table as a
left join User login information table as b on a. user ID = b. user ID
) c
group by c. user ID,c. The login time
) d; Query results :

【 The test point of this question 】
1. Understanding of common indicators , For example, the number of retained users 、 Retention .
2. Flexible use case To statistics when Function and group by Perform custom column statistics .
3. Encountered only one table , But the problem of counting time intervals , We need to think of using self connection to find the time interval , Similar to finding continuity appear N The content of this time 、 sound of dripping water 2020 True job title 、 Chain home interview questions : How to analyze retention .


▼ Click on 「 Read the original 」
▼ Unlock more data analysis courses
边栏推荐
- 攻防演练复盘
- Is it safe and reliable to open an account in Caixue school and make new debts?
- leetcode96不同的二叉搜索树
- Node——添加压缩文件
- I want to ask, which is the better choice for securities companies? I don't understand. Is it safe to open an account online now?
- Openvino model performance evaluation tool DL workbench
- Relatively easy to understand PID understanding
- Accelerator systems initiative is an independent non-profit organization
- 回顾数据脱敏系统
- 使用htaccess文件禁止目录里的脚本执行权限
猜你喜欢

起床困难综合症(按位贪心)

Heketi record

Asp . Text of automatic reply to NETCORE wechat subscription number

export default 导出的对象,不能解构问题,和module.exports的区别

Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
Linux CentOS7安装Oracle11g的超完美新手教程

SQL数据分析之流程控制语句【if,case...when详解】

Windows installation WSL (II)

GCC compilation

Key points of security agreement
随机推荐
SQL数据分析之流程控制语句【if,case...when详解】
S32Kxxx bootloader之UDS bootloader
求逆序数的三个方法
Node——Egg 实现上传文件接口
const // It is a const object... class nullptr_ t
vue 强制清理浏览器缓存
Accelerator systems initiative is an independent non-profit organization
Which securities company is safer to open a stock account
Is it safe for qiniu college to open an account? How to open an account?
Download the online video m3u8 tutorial
Learn online case practice
Dongge cashes in and the boss retires?
【CMake】Qt creator 里面的 cmake 配置
MySQL: the difference between insert ignore, insert and replace
Using multithreaded callable to query Oracle Database
Linux CentOS7安装Oracle11g的超完美新手教程
Guide d'installation du serveur SQL
攻防演练复盘
Use the htaccess file to prohibit the script execution permission in the directory
[QT] QT cannot find a solution to the compiler using msvc2017