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

select o.date,concat(round(o.a/v.b*100,1),'%') cr
from (
    select date(visit_time) date,count(distinct user_id) b
    from visit_tb 
    group by date(visit_time)
) v
join (
    select date(order_time) date,count(distinct user_id) a
    from order_tb
    group by date(order_time)
) o on v.date=o.date
group by o.date
order by o.date

没想到最后是用两个子查询join做出来的

另:先四舍五入再乘100和先*100后四舍五入结果不同

全部评论

相关推荐

牛客73617529...:无端端被你骂一句
点赞 评论 收藏
分享
05-26 22:25
门头沟学院 Java
Java小肖:不会是想叫你过去把你打一顿吧,哈哈哈
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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