2
比方说,我有4个表入门台式机的平均数量
Order (OrderID, ComputerID, Quantity, Type_PC)
Computer (ComputerID, Model)
Desktop (ComputerID, specs, Cost)
Laptop (ComputerID, specs, Cost)
我试图让每个订单台式机的平均数量。
SELECT order.orderid, avg(order.quantity) AS AvgDesktopsSold
FROM computer, order
WHERE order.type_pc ="desktop" AND computer.computerid = order.computerid;
我有说Column "Desktop" not found
你能帮我解决这个问题,SQL的错误?
使用单引号“桌面”,而不是双引号。双引号使其被解释为列名。 – GreyBeardedGeek
'order'是一个关键的sql字,我强烈建议将表名更改为其他名称以帮助查询查询的可读性。 – Tigger
每个订单只能有一种类型的PC?这似乎是错误的。如果有人想要订购两台笔记本电脑和两台台式电脑怎么办?你将不得不创建两个订单。当你开始销售笔记本时,你必须创建一个新表。 –