当前位置:网站首页>[PDD interview] analyze the activity of applications (cameras) in mobile phones
[PDD interview] analyze the activity of applications (cameras) in mobile phones
2022-07-23 20:30:00 【South Lake Fishing Song】
Big factory SQL Interview questions sql Data analysis
(1) Without considering the business data , The same user may log in multiple times , Or the same customer can place multiple orders in one day :
-- select sum(TRUE); → by 1 ;
select a. Landing time as dt
,count(distinct a.user_id) as Number of active users
,sum(datediff(b. Landing time ,a. Landing time ) = 1) as Number of users retained in the next day
,sum(datediff(b. Landing time ,a. Landing time ) = 3) as Number of users retained in three days
,sum(datediff(b. Landing time ,a. Landing time ) = 7) as Number of users retained in seven days
,concat(round(sum(datediff(b. Landing time ,a. Landing time ) = 1)/ count(distinct a.user_id)*100,0),'%') as Next day retention rate
,concat(round(sum(datediff(b. Landing time ,a. Landing time ) = 3)/ count(distinct a.user_id)*100,1),'%') as Three day retention rate
,concat(round(sum(datediff(b. Landing time ,a. Landing time ) = 7)/ count(distinct a.user_id)*100,2),'%') as Seven day retention rate
from ( SELECT MemberID AS user_id, date(STime) AS Landing time
FROM OrderList
WHERE MemberID IS NOT NULL and shopid = 'WDGC'
AND (date(STime) < '2016-01-10')
) as a
left join( SELECT MemberID AS user_id, date(STime) AS Landing time
FROM OrderList
WHERE MemberID IS NOT NULL and shopid = 'WDGC'
AND (date(STime) < '2016-01-10')
) as b
on a.user_id = b.user_id
group by a. Landing time ;
Finally, the next day 、 Three days 、 There is too much retention in seven days :
Correct insurance practices : I have considered weight removal :
select d.a_t,
count(distinct d. user id) as Number of active users ,
count(distinct case when d. The time interval =1 then d. user id
else null
end) as The amount retained on the next day ,
count(distinct case when The time interval =1 then d. user id
else null
end) /count(distinct d. user id) as Next day retention rate ,
count(distinct case when d. The time interval =3 then d. user id
else null
end) as 3 Daily retention ,
count(distinct case when The time interval =3 then d. user id
else null
end) /count(distinct d. user id) as 3 Daily retention rate ,
count(distinct case when d. The time interval =7 then d. user id
else null
end) as 7 Daily retention ,
count(distinct case when The time interval =7 then d. user id
else null
end) /count(distinct d. user id) as 7 Daily retention rate
from
(
select *
,timestampdiff(day,a_t,b_t) as The time interval
from ( select a.` user id`
,a. Landing time as a_t
,b. Landing time as b_t
from ( SELECT MemberID AS user id, date(STime) AS Landing time
FROM OrderList
WHERE MemberID IS NOT NULL and shopid = 'WDGC'
AND (date(STime) < '2016-01-10')
) as a
left join( SELECT MemberID AS user id, date(STime) AS Landing time
FROM OrderList
WHERE MemberID IS NOT NULL and shopid = 'WDGC'
AND (date(STime) < '2016-01-10')
)as b
on a.` user id`=b.` user id`
) as c
) as d
group by d.a_t;

边栏推荐
- When using polymorphism, two ideas to judge whether it can be transformed downward
- JDK安装包和Mysql安装包整理
- Lingo 基本使用
- Leetcode 219. duplicate Element II exists (yes, resolved)
- [Q] Error redirecting nmcli manual to TXT text
- After the input error of next numerical data type () occurs, it can still be input normally next time
- 牛客C基础题练习
- 如何给电脑系统重置系统?方法其实很简单
- shell命令及运行原理
- 使用TinkerPop框架对GDB增删改查
猜你喜欢

Osgearth uses sundog's Triton ocean and silverlining cloud effects

微软网站上关于在Edge浏览器中打开或关闭smartScreen的说明有误

小程序頭像組樣式

数组——11. 盛最多水的容器

NLP领域历史最全必读经典论文分类整理分享(附中文解析)

Complex data processing of multi subsystem and multi business modules -- project development practice based on instruction set Internet of things operating system

How to add to-do items for win11 widgets? Win11 method of adding to-do widget

Model loading of assimp Library under QT

Flink Catalog解读

数组——59. 螺旋矩阵 II
随机推荐
21. Mix in details
2022DASCTF MAY
VRRP+MSTP配置详解【华为eNSP实验】
数组——11. 盛最多水的容器
Cesium 事件详解(鼠标事件、相机事件、键盘事件、场景触发事件)
Baidu map data visualization
剑指 Offer II 115. 重建序列
【问题处理】Merge made by the ‘ort‘ strategy.
【力扣】最接近的三数之和
如何给电脑系统重置系统?方法其实很简单
OpenLayers实例-Accessible Map-可访问的地图
Task03 notes 2
Viewing the "Empathy" energy of iqoo 10 pro from 200W super flash charging
Cesium knockout怎么用?
[force deduction] sum of three numbers
从ACL 2022 Onsite经历看NLP热点
Leetcode 151. invert words in strings
D2Admin框架基本使用
How to add to-do items for win11 widgets? Win11 method of adding to-do widget
Lingo 基本使用