美文网首页
第五章 练习题

第五章 练习题

作者: susupp | 来源:发表于2018-07-23 16:11 被阅读0次

5.1

CREATE VIEW ViewPractices5_1 AS SELECT
    product_name,
    sale_price,
    regist_date
FROM
    Product
WHERE
    sale_price >= 1000
AND regist_date = '2009-09-20';

5.2

INSERT INTO ViewPractice5_1
VALUES
    ('刀子', 300, '2009-11-02');

报错
5.3

SELECT
    product_id,
    product_name,
    product_type,
    sale_price,
    AVG(sale_price) AS sale_price_all
FROM
    product;

5.4

CREATE VIEW AvgPriceByType AS SELECT
    product_id,
    product_name,
    product_type,
    sale_Price,
    (
        SELECT
            avg(sale_price)
        FROM
            product AS p2
        WHERE
            p1.product_type = p2.product_type
    ) AS avg_sale_price
FROM
    product AS p1;

相关文章

网友评论

      本文标题:第五章 练习题

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