题解 | 计算每天的新用户占比
计算每天的新用户占比
https://www.nowcoder.com/practice/c95ddc4968044035853c22e000a0ec21
select
login_date as dt,
count(distinct uid) as total_user_num,
concat(
round(
count(distinct case when rn = 1 then uid end)
/ count(distinct uid) * 100,
1
),
'%'
) as new_user_rate
from (
select
uid,
login_date,
row_number() over (partition by uid order by login_date) as rn
from user_login_tb
) c
group by login_date
order by login_date;

查看8道真题和解析