美文网首页
第六章 练习题

第六章 练习题

作者: susupp | 来源:发表于2018-07-24 13:15 被阅读0次

    6.1

    SELECT
        product_name,
        purchase_price
    FROM
        Product
    WHERE
        purchase_price NOT IN (500, 2800, 5000);
    

    返回4条结果

    SELECT
        product_name,
        purchase_price
    FROM
        Product
    WHERE
        purchase_price NOT IN (500, 2800, 5000, NULL);
    

    不返回任何结果

    6.2

    SELECT
        sum(
            CASE
            WHEN sale_price <= 1000 THEN
                1
            ELSE
                0
            END
        ) AS low_price,
        sum(
            CASE
            WHEN sale_price BETWEEN 1001
            AND 3000 THEN
                1
            ELSE
                0
            END
        ) AS mid_price,
        sum(
            CASE
            WHEN sale_price >= 3001 THEN
                1
            ELSE
                0
            END
        ) AS high_price
    FROM
        product;
    
    

    相关文章

      网友评论

          本文标题:第六章 练习题

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