当前位置:网站首页>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
边栏推荐
- Graduation season is both a farewell and a new beginning
- Regular expression collection
- 多表操作-一对一,一对多与多对多
- Intelligent operation and maintenance practice: banking business process and single transaction tracking
- 挖财学堂开户打新债安全可靠嘛?
- ADO. Net SqlDataAdapter object
- Flow control statement of SQL data analysis [if, case... When detailed]
- From 20s to 500ms, I used these three methods
- SQL Server 安裝指南
- PWN attack and defense world cgpwn2
猜你喜欢
Jielizhi, production line assembly link [chapter]
Leetcode96 different binary search trees
Key points of security agreement
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
EMC circuit protection device for surge and impulse current protection
Download the online video m3u8 tutorial
Linux CentOS7安装Oracle11g的超完美新手教程
B tree and b+tree of MySQL
[QT] qtcreator uninstall and installation (abnormal state)
Jielizhi, production line assembly link [chapter]
随机推荐
2023款雷克萨斯ES产品公布,这回进步很有感
多表操作-一对一,一对多与多对多
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
leetcode96不同的二叉搜索树
Leetcode 96 différents arbres de recherche binaires
Digital transformation has a long way to go, so how to take the key first step
Qt5.12.9 migration tutorial based on Quanzhi H3
vue 强制清理浏览器缓存
How to improve data quality
Mysql database driver (JDBC Driver) jar package download
JS——图片转base码 、base转File对象
[QT] test whether QT can connect to the database
数据分析方法论与前人经验总结【笔记干货】
Node——Egg 实现上传文件接口
[CTF] bjdctf 2020 Bar _ Bacystack2
【QT】Qt 使用MSVC2017找不到编译器的解决办法
An intern's journey to cnosdb
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
Heketi record
Jielizhi, production line assembly link [chapter]