创建视图v_sales_all,其功能是查询所有客户的客户编号customer_id、姓名name、所买商品的名称Item_name、类别category、售价retail_price、折扣discount和数量quantity。
连接这几个表,从这些表中取需要的字段:
create view v_sales_all as
select c.customer_id, c.name, i.item_name, i.category, i.retail_price, od.discount, od.quantity
from customers c, orders o, order_details od, items i
where c.customer_id=o.customer_id
and o.order_id=od.order_id
and od.item_id=i.item_id