题解 | 统计用户从访问到下单的转化率

统计用户从访问到下单的转化率

https://www.nowcoder.com/practice/eaff8684aed74e208300f2737edbb083

with t1 as (
    select count(distinct user_id) as u_id ,date(visit_time) as vt from
    visit_tb group by date(visit_time)
),
t2 as (
    select count(distinct user_id) as u_id,date(order_time) as ot from
    order_tb group by date(order_time)
)
select vt as date, concat(round(t2.u_id/t1.u_id*100,1),'%') as cr
from t1 left join t2 on t1.vt = t2.ot
order by vt

要注意的是百分数要放在roud函数里,而不是放在外面,不然会导师精确度不高且分位数有区别

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务