-- 对金额大于4000元的商品,按照品牌分组,获取每组商品的总金额,只显示总金额大于7000元的、并按照总金额的降序排列
SELECT brand,SUM(price) getSum FROM product
WHERE price > 4000
GROUP BY brand
HAVING getSum > 7000
ORDER BY getSum DESC;
select 查询的字段列表
from 查询的表
[where 查询的条件]
[group by 分组的列]
[having 分组后的条件]
[order by 排序条件]
[limit 起始索引,每页条数]