题解 | 统计各等级会员用户下订单总额
SELECT vip, IF(SUM(order_price) IS NOT NULL, SUM(order_price), 0) AS order_total FROM order_tb ot RIGHT JOIN uservip_tb ut ON ot.user_id = ut.user_id GROUP BY vip ORDER BY order_total DESC;
SELECT vip, IF(SUM(order_price) IS NOT NULL, SUM(order_price), 0) AS order_total FROM order_tb ot RIGHT JOIN uservip_tb ut ON ot.user_id = ut.user_id GROUP BY vip ORDER BY order_total DESC;
相关推荐