1. 创建视图vw_count:查询顾客“马云”一共购买了多少部小米Note2,字段分别为客户姓名(cname),商品名字(pname),物品总数量(osum)
程序员文章站
2024-03-20 13:03:40
...
CREATE VIEW vw_count AS SELECT
cname,
pname,
SUM(ocount) osum
FROM
customer,
product,
orders
WHERE
customer.cname = '马云'
AND customer.cid = orders.cid
AND product.pid = orders.pid
AND product.pname = '小米Note2'
上一篇: 7.查询性能优化