排名

用户解题统计

过去一年提交了

勋章 ①金银铜:在竞赛中获得第一二三名;②好习惯:自然月10天提交;③里程碑:解决1/2/5/10/20/50/100/200题;④每周打卡挑战:完成每周5题,每年1月1日清零。

收藏

收藏日期 题目名称 解决状态
没有收藏的题目。

评论笔记

评论日期 题目名称 评论内容 站长评论
没有评论过的题目。

提交记录

提交日期 题目名称 提交代码
2025-12-17 会员与非会员的日均观看视频数量 
select
m_flg,
round(avg(num),2)as num_1
from (
select
m_flg,
bilibili_t100.usr_id,
date(v_tm) as date1,
count(v_id) as num
from bilibili_t100
left join bilibili_t20
on bilibili_t20.usr_id = bilibili_t100.usr_id
where date(v_tm) between '2021-02-01' and '2021-02-28'
group by 1,2,3
) aa
group by 1
2025-12-17 会员与非会员的日均观看视频数量 
select
m_flg,
round(avg(num),2)as num_1
from (
select
m_flg,
bilibili_t100.usr_id,
date(v_tm) as date1,
count(distinct v_id) as num
from bilibili_t100
left join bilibili_t20
on bilibili_t20.usr_id = bilibili_t100.usr_id
where date(v_tm) between '2021-02-01' and '2021-02-28'
group by 1,2,3
) aa
group by 1
2025-12-17 会员与非会员的日均观看视频数量 
select
m_flg,
round(avg(num_1),2) as num_2
from (
select
m_flg,
usr_id,
avg(num)as num_1
from (
select
m_flg,
bilibili_t100.usr_id,
date(v_tm) as date1,
count(distinct v_id) as num
from bilibili_t100
left join bilibili_t20
on bilibili_t20.usr_id = bilibili_t100.usr_id
where date(v_tm) between '2021-02-01' and '2021-02-28'
group by 1,2,3
) aa
group by 1,2
) bb
group by 1
2025-12-17 会员与非会员的日均观看视频数量 
select
m_flg,
avg(num_1) as num_2
from (
select
m_flg,
usr_id,
avg(num)as num_1
from (
select
m_flg,
bilibili_t100.usr_id,
date(v_tm) as date1,
count(distinct v_id) as num
from bilibili_t100
left join bilibili_t20
on bilibili_t20.usr_id = bilibili_t100.usr_id
where date(v_tm) between '2021-02-01' and '2021-02-28'
group by 1,2,3
) aa
group by 1,2
) bb
group by 1
2025-12-16 窗口函数(4)越来越喜欢召妓,窗口函数用累计(2) 
select
distinct
left(trx_time,7)as month,
sum(trx_amt) over (partition by mch_typ,left(trx_time,7))
from cmb_usr_trx_rcd 
left join cmb_mch_typ
on cmb_usr_trx_rcd.mch_nm=cmb_mch_typ.mch_nm
where
mch_typ='休闲娱乐'
and trx_time like ('2023%')
and usr_id=5201314520
2025-12-16 S1年级物理成绩前10名(1) 
select 
students.student_id,
students.name,
scores.score,
row_number()over (partition by subject order by score desc)
from students
left join scores
on students.student_id=scores.student_id
where 
subject='物理'
and grade_code='S1'
limit 10
2025-12-16 S1年级物理成绩前10名(1) 
select 
students.student_id,
students.name,
scores.score,
rank() over (partition by subject order by score desc)as '排名'
from students
left join scores
on students.student_id=scores.student_id
where 
subject='物理'
and grade_code='S1'
limit 10
2025-12-16 S1年级物理成绩前10名(1) 
select 
students.student_id,
students.name,
scores.score,
rank() over (partition by subject order by score desc)
from students
left join scores
on students.student_id=scores.student_id
where 
subject='物理'
and grade_code='S1'
limit 10
2025-12-15 不分类别的最火直播间 
select
ks_live_t1.live_id,
ks_live_t2.live_nm,
count(ks_live_t1.usr_id) as 进入人次
from ks_live_t1
left join ks_live_t2
on ks_live_t1.live_id=ks_live_t2.live_id
where ks_live_t1.enter_time between'2021-09-12 23:00:00'and'2021-09-12 23:59:59' 
group by 1,2
order by count(ks_live_t1.usr_id) desc
limit 5
2025-12-15 不分类别的最火直播间 
select 
ks_live_t1.live_id,
ks_live_t2.live_nm,
count(ks_live_t1.usr_id)as'进入人次'
from ks_live_t1
left join ks_live_t2
on ks_live_t1.live_id=ks_live_t2.live_id
where 
ks_live_t1.enter_time between'2021-09-12 23:00:00' and '2021-09-12 23:59:59'
group by 1,2
order by count(ks_live_t1.usr_id) desc
limit 5
2025-12-15 分组与聚合函数(5)想知道何时成瘾,用Max Or Min? 
select 
usr_id,
min(trx_time)as first_time,
mch_nm
from cmb_usr_trx_rcd
where
usr_id=5201314520
and mch_nm='红玫瑰按摩保健休闲'
2025-12-15 分组与聚合函数(1)Money全都花在哪,GroupBy来查一查 
select
mch_nm,
sum(trx_amt)as sum_trx_amt
from cmb_usr_trx_rcd
where date(trx_time) between '2024-01-01'and'2024-12-31'
and usr_id=5201314520
group by 1
2025-12-15 曝光量最大的商品 
select
*
from tb_cst_bas_inf
where
age between 35 and 45
and gdr='M'
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
with unique_login as (
  select
        usr_id,
        date(login_time) AS login_date
    from
        user_login_log
    where
        datediff(current_date,date(login_time)) <= 30
    group by 1,2
),
retention as (
select
first.usr_id,
first.login_date,
second.login_date as rentention_date
from unique_login as first
left join unique_login as second
on first.usr_id = second.usr_id
and datediff(second.login_date,first.login_date) between 1 and 14 
)
 select
 first_login_date,
 round(rent_1/num*100,2) as t_plus_1_rentention_rate,
 round(rent_3/num*100,2) as t_plus_3_rentention_rate,
 round(rent_7/num*100,2) as t_plus_7_rentention_rate,
 round(rent_14/num*100,2) as t_plus_14_rentention_rate
 from (
 select
 login_date as first_login_date,
 count(distinct usr_id) num,
 count(distinct if(datediff(rentention_date,login_date)=1,usr_id,null)) rent_1,
 count(distinct if(datediff(rentention_date,login_date)=3,usr_id,null)) rent_3,
 count(distinct if(datediff(rentention_date,login_date)=7,usr_id,null)) rent_7,
 count(distinct if(datediff(rentention_date,login_date)=14,usr_id,null)) rent_14
 from retention
 group by 1
 ) total
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
select
first_login_date,
round(lead_1_num/num*100,2) as t_plus_1_retention_rate,
round(lead_3_num/num*100,2) as t_plus_3_retention_rate,
round(lead_7_num/num*100,2) as t_plus_7_retention_rate,
round(lead_14_num/num*100,2) as t_plus_14_retention_rate
from (
select
first_login_date,
count(distinct usr_id) num,
count(distinct if(datediff(lead_1,first_login_date)=1,usr_id,null)) lead_1_num,
count(distinct if(datediff(lead_3,first_login_date)=3,usr_id,null)) lead_3_num,
count(distinct if(datediff(lead_7,first_login_date)=7,usr_id,null)) lead_7_num,
count(distinct if(datediff(lead_14,first_login_date)=14,usr_id,null)) lead_14_num
from (
select
first_login_date,
usr_id,
lead(first_login_date,1) over (partition by usr_id order by first_login_date) as lead_1,
lead(first_login_date,3) over (partition by usr_id order by first_login_date) as lead_3,
lead(first_login_date,7) over (partition by usr_id order by first_login_date) as lead_7,
lead(first_login_date,14) over (partition by usr_id order by first_login_date) as lead_14
from (
select date(login_time) as first_login_date,
usr_id
from user_login_log 
where datediff(current_date,date(login_time)) <= 30
group by 1,2
) user
) total
group by 1
) final
order by first_login_date
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
select
first_login_date,
round(lead_1_num/num*100,2) as t_plus_1_retention_rate,
round(lead_3_num/num*100,2) as t_plus_3_retention_rate,
round(lead_7_num/num*100,2) as t_plus_7_retention_rate,
round(lead_14_num/num*100,2) as t_plus_14_retention_rate
from (
select
first_login_date,
count(distinct usr_id) num,
count(distinct if(datediff(lead_1,first_login_date)=1,usr_id,null)) lead_1_num,
count(distinct if(datediff(lead_3,first_login_date)=3,usr_id,null)) lead_3_num,
count(distinct if(datediff(lead_7,first_login_date)=7,usr_id,null)) lead_7_num,
count(distinct if(datediff(lead_14,first_login_date)=14,usr_id,null)) lead_14_num
from (
select
first_login_date,
usr_id,
lead(first_login_date,1) over (partition by usr_id order by first_login_date) as lead_1,
lead(first_login_date,3) over (partition by usr_id order by first_login_date) as lead_3,
lead(first_login_date,7) over (partition by usr_id order by first_login_date) as lead_7,
lead(first_login_date,14) over (partition by usr_id order by first_login_date) as lead_14
from (
select date(login_time) as first_login_date,
usr_id
from user_login_log 
where datediff(current_date,date(login_time)) <= 90
group by 1,2
) user
) total
group by 1
) final
order by first_login_date
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
select
first_login_date,
round(lead_1_num/num*100,2) as t_plus_1_retention_rate,
round(lead_3_num/num*100,2) as t_plus_3_retention_rate,
round(lead_7_num/num*100,2) as t_plus_7_retention_rate,
round(lead_14_num/num*100,2) as t_plus_14_retention_rate
from (
select
first_login_date,
count(distinct usr_id) num,
count(distinct if(datediff(lead_1,first_login_date)=1,usr_id,null)) lead_1_num,
count(distinct if(datediff(lead_3,first_login_date)=3,usr_id,null)) lead_3_num,
count(distinct if(datediff(lead_7,first_login_date)=7,usr_id,null)) lead_7_num,
count(distinct if(datediff(lead_14,first_login_date)=14,usr_id,null)) lead_14_num
from (
select
first_login_date,
usr_id,
lead(first_login_date,1) over (partition by usr_id order by first_login_date) as lead_1,
lead(first_login_date,3) over (partition by usr_id order by first_login_date) as lead_3,
lead(first_login_date,7) over (partition by usr_id order by first_login_date) as lead_7,
lead(first_login_date,14) over (partition by usr_id order by first_login_date) as lead_14
from (
select date(login_time) as first_login_date,
usr_id
from user_login_log 
where datediff(current_date,date(login_time)) <= 90
group by 1,2
) user
) total
group by 1
) final
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
select
first_login_date,
round(lead_1_num/num*100,2) as t_plus_1_retention_rate,
round(lead_3_num/num*100,2) as t_plus_3_retention_rate,
round(lead_7_num/num*100,2) as t_plus_7_retention_rate,
round(lead_14_num/num*100,2) as t_plus_14_retention_rate
from (
select
first_login_date,
count(distinct usr_id) num,
count(distinct if(datediff(lead_1,first_login_date)=1,usr_id,null)) lead_1_num,
count(distinct if(datediff(lead_3,first_login_date)=3,usr_id,null)) lead_3_num,
count(distinct if(datediff(lead_7,first_login_date)=7,usr_id,null)) lead_7_num,
count(distinct if(datediff(lead_14,first_login_date)=14,usr_id,null)) lead_14_num
from (
select
first_login_date,
usr_id,
lead(first_login_date,1) over (partition by usr_id order by first_login_date) as lead_1,
lead(first_login_date,3) over (partition by usr_id order by first_login_date) as lead_3,
lead(first_login_date,7) over (partition by usr_id order by first_login_date) as lead_7,
lead(first_login_date,14) over (partition by usr_id order by first_login_date) as lead_14
from (
select date(login_time) as first_login_date,
usr_id
from user_login_log 
where datediff(current_date,date(login_time)) <= 30
group by 1,2
) user
) total
group by 1
) final
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
select
first_login_date,
lead_1_num/num*100 as t_plus_1_retention_rate,
lead_3_num/num*100 as t_plus_3_retention_rate,
lead_7_num/num*100 as t_plus_7_retention_rate,
lead_14_num/num*100 as t_plus_14_retention_rate
from (
select
first_login_date,
count(distinct usr_id) num,
count(distinct if(datediff(lead_1,first_login_date)=1,usr_id,null)) lead_1_num,
count(distinct if(datediff(lead_3,first_login_date)=3,usr_id,null)) lead_3_num,
count(distinct if(datediff(lead_7,first_login_date)=7,usr_id,null)) lead_7_num,
count(distinct if(datediff(lead_14,first_login_date)=14,usr_id,null)) lead_14_num
from (
select
first_login_date,
usr_id,
lead(first_login_date,1) over (partition by usr_id order by first_login_date) as lead_1,
lead(first_login_date,3) over (partition by usr_id order by first_login_date) as lead_3,
lead(first_login_date,7) over (partition by usr_id order by first_login_date) as lead_7,
lead(first_login_date,14) over (partition by usr_id order by first_login_date) as lead_14
from (
select date(login_time) as first_login_date,
usr_id
from user_login_log 
where datediff(current_date,date(login_time)) <= 30
group by 1,2
) user
) total
group by 1
) final
2025-10-26 抖音面试真题(2)一次性计算T+1、T+3、T+7、T+14留存率 
select
first_login_date,
lead_1_num/num as t_plus_1_retention_rate,
lead_3_num/num as t_plus_3_retention_rate,
lead_7_num/num as t_plus_7_retention_rate,
lead_14_num/num as t_plus_14_retention_rate
from (
select
first_login_date,
count(distinct usr_id) num,
count(distinct if(datediff(lead_1,first_login_date)=1,usr_id,null)) lead_1_num,
count(distinct if(datediff(lead_3,first_login_date)=3,usr_id,null)) lead_3_num,
count(distinct if(datediff(lead_7,first_login_date)=7,usr_id,null)) lead_7_num,
count(distinct if(datediff(lead_14,first_login_date)=14,usr_id,null)) lead_14_num
from (
select
first_login_date,
usr_id,
lead(first_login_date,1) over (partition by usr_id order by first_login_date) as lead_1,
lead(first_login_date,3) over (partition by usr_id order by first_login_date) as lead_3,
lead(first_login_date,7) over (partition by usr_id order by first_login_date) as lead_7,
lead(first_login_date,14) over (partition by usr_id order by first_login_date) as lead_14
from (
select date(login_time) as first_login_date,
usr_id
from user_login_log 
where datediff(current_date,date(login_time)) <= 30
group by 1,2
) user
) total
group by 1
) final