美文网首页
2019-07-20

2019-07-20

作者: Sam_6155 | 来源:发表于2019-07-20 14:57 被阅读0次

-- 创建视图的语句
CREATE VIEW AvgPriceByType AS
SELECT product_id,
product_name,
product_type,
sale_price,
(SELECT AVG(sale_price)
FROM Product P2
WHERE P1.product_type = P2.product_type
GROUP BY P1.product_type) AS avg_sale_price
FROM Product P1;

-- 确认视图内容
SELECT * FROM AvgPriceByType;

相关文章

网友评论

      本文标题:2019-07-20

      本文链接:https://www.haomeiwen.com/subject/suculctx.html