SELECT b.vip, COALESCE(SUM(a.order_price),0) AS order_total FROM order_tb AS a RIGHT JOIN uservip_tb AS b ON (a.user_id = b.user_id) GROUP BY b.vip ORDER BY order_total DESC;