-- 按品牌分组,获取每组商品总金额
SELECT brand,SUM(price) FROM product GROUP BY brand; -- 对于金额大于4000 的商品 按品牌分组,获取每组商品总金额
SELECT brand,SUM(price) FROM product WHERE price > 4000 GROUP BY brand;-- 对于金额大于4000 的商品 按品牌分组,获取每组商品总金额 只显示总金额大于7000元的
SELECT brand,SUM(price)getsum FROM product WHERE price>4000 GROUP BY brand HAVING getsum > 7000;-- 对于金额大于4000 的商品 按品牌分组,获取每组商品总金额 只显示总金额大于7000元的 并且按总金额降序排序
SELECT brand,SUM(price)getsum FROM product WHERE price>4000 GROUP BY brand HAVING getsum > 7000 ORDER BY getsum DESC;