大数据开发面经汇总【持续更新...】
我的大数据学习之路
大数据开发面试笔记V6.0
来自字节、阿里、腾讯、pdd等数据研发一面二面
INSERT INTO ods_usr_login_log VALUES
('001','20240701'),
('001','20240701'),
('002','20240701'),
('003','20240701'),
('001','20240702'),
('002','20240702'),
('002','20240702'),
('001','20240703'),
('002','20240704'),
('004','20240704')
;
with t1 as (
select user_id, cast(min(login_dt) as date) as dt
from ods_usr_login_log
group by user_id
),
t2 as (
select user_id, cast(login_dt as date) as dt
from ods_usr_login_log
group by user_id, cast(login_dt as date)
)
select
t1.dt
,count(distinct case when datediff(t2.dt, t1.dt) = 1 then t2.user_id else null end) / count(distinct t1.user_id) as retain_1d_rate
,count(distinct case when datediff(t2.dt, t1.dt) = 3 then t2.user_id else null end) / count(distinct t1.user_id) as retain_3d_rate
from t1
left join t2
on t1.user_id = t2.user_id
group by t1.dt
;
#数据人的面试交流地##校招过来人的经验分享##sql##数据库#