使用右连接,以Orders表为基准
select cust_id,sum(item_price*quantity)as total_ordered
from OrderItems a
right join Orders b on a.order_num=b.order_num
group by cust_id
order by total_ordered desc;
使用右连接,以Orders表为基准
select cust_id,sum(item_price*quantity)as total_ordered
from OrderItems a
right join Orders b on a.order_num=b.order_num
group by cust_id
order by total_ordered desc;