题解 | 统计各等级会员用户下订单总额
with tb1 as (select vip, sum(order_price) as order_total from order_tb left join uservip_tb using(user_id) group by vip), tb2 as (select vip from uservip_tb group by vip) select vip, case when order_total is null then 0 else order_total end as order_total from tb1 right join tb2 using(vip) order by order_total desc
感觉有点麻烦的一个方法