题解 | 下单最多的商品

下单最多的商品

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

select
    product_id,
    count(*) as cnt
from
    user_client_log
where
    step = 'order'
group by
    product_id
order by
    cnt desc, product_id
limit 1;

这个题竟然不需要考虑支付失败的时候,并且还有一点需要注意,如果只需要输出下单次数最大的哪一个的话,好像不需要窗口函数排序,只需要limit 1即可。

【也就是不需要分组直接筛选top1,并且不考虑并列可以是直接limit1】

全部评论

相关推荐

点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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