mysql - 当我试图找到平均值时出现错误
问题描述
SELECT AVG(product.product_price)
from product
, customer
, orderline
, orders
WHERE product.product_id = orderline.product_id
AND orderline.order_id = orders.order_id
and = orders.cust_id = customer.cust_id
AND customer.city LIKE 'Tuscon'
group
by product.name
我正在尝试查找客户在图森订购的产品的平均价格
解决方案
我在第 5 行看到了一个语法问题。另外,不需要将 where 子句放在大括号中。此外,您尝试使用 JOIN 而不是“,”。
SELECT product.name, AVG(product.product_price)
from product
inner join orderline on product.product_id = orderline.product_id
inner join orders on orderline.order_id = orders.order_id
inner join customer on orders.cust_id = customer.cust_id
WHERE customer.city LIKE 'Tuscon'
group by product.name
推荐阅读
- java - Gradle:如何使用 Maven 项目源作为依赖项
- tensorflow - 什么是 vggish_model.ckpt 和 vggish_pca_params.npz
- c# - 如何将 Json 对象序列化/反序列化为 C# 类
- javascript - 有人可以帮我在javascript中将字符串转换为对象吗
- c++ - 为什么 ILS_best_p 没有给我我想要的向量?
- android - 如何修复错误字段以在 android studio 上转换“c:/user/...”
- python-3.x - Sqlalchemy,合并两个查询
- python - 如何修复:- libmxnet.so:无法打开共享对象文件:没有这样的文件或目录
- javascript - 为什么一定要加上[I]?
- r - 插入符号(R)中的summary()和print()有什么区别