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;
SELECT * FROM Product ORDER BY regist_date DESC, sale_price;
原文地址:https://www.cnblogs.com/MarlonKang/p/12228117.html
时间: 2024-10-09 18:50:16