select t1.vip,
#把null替换为0
if(t1.order_total is null, 0, t1.order_total) as order_total
from (select vip,
sum(order_price) order_total
from uservip_tb ut
left join order_tb ot
using (user_id)
group by vip
order by order_total desc) as t1

京公网安备 11010502036488号