题解 | 统计各等级会员用户下订单总额
统计各等级会员用户下订单总额
https://www.nowcoder.com/practice/48dd35a3dd8c4e1494db36b097a03300
select distinct vip, sum(case when order_price is NULL then 0 else order_price end) as order_total from order_tb o right join uservip_tb u on o.user_id = u.user_id group by vip order by order_total desc
这里用的是case语句,也可以用IF语句,if(expr1,expr2,expr3)
expr1:条件表达式(布尔值)
expr2: when expr1 is true, return expr2
expr3: when expr1 is false or null, return expr3
OPPO公司福利 1229人发布
查看6道真题和解析