题解 | 统计各等级会员用户下订单总额

统计各等级会员用户下订单总额

https://www.nowcoder.com/practice/48dd35a3dd8c4e1494db36b097a03300

with
t1 as(
    select
        vip,
        sum(order_price) as psum
    from
        order_tb right join uservip_tb using(user_id)
    group by
        vip
)
,t2 as(
    select
        vip,
        (
            case
                when psum is null then 0
                else psum
            end
        ) as order_total
    from
        t1
    order by
        order_total desc
)

select * from t2

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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