在多个表中都含有的元组,防止计算机不能读取,我们应该标明这个元组属于哪个表中。我们直接连表,帅选我们要的元组。OrderTotal每个顾客只有一项,所以不需要sum 以下是代码:

select cust_name,o.order_num,quantity* item_price OrderTotal
from Customers c
join Orders o on o.cust_id = c.cust_id
join OrderItems oi on o.order_num = oi.order_num
order by cust_name, o.order_num;
-- 多个表中含有的元组,需要标明在那个表中