题解 | 查询单日多次下订单的用户信息?

SELECT 
    order_date,
    t1.user_id,
    order_nums,
    vip
FROM
    (SELECT 
        SUBSTRING(order_time,1,10) order_date,
        user_id,
        COUNT(DISTINCT ot.order_id) order_nums
    FROM order_tb ot
    GROUP BY user_id, SUBSTRING(order_time,1,10)
)t1
JOIN uservip_tb ut ON t1.user_id = ut.user_id
WHERE order_nums > 1

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务