product_name VARCHAR数据类型不支持 聚合函数SUM 求和算数运算;
SELECT子句 后面只能存在 GROUP BY子句中指定的列名(也就是聚合键);
子句的书写顺序 ,1. SELECT → 2. FROM → 3. WHERE → 4. GROUP BY
SELECT product_type, SUM(sale_price), SUM(purchase_price) FROM Product GROUP BY product_type HAVING SUM(sale_price) > SUM(purchase_price) * 1.5;View Code
SELECT * FROM Product ORDER BY regist_date DESC, sale_price;View Code