[英]SQL query aggregating values isn't working?
Here's my query: 这是我的查询:
SELECT customers.state, SUM( orders.quantity * items.unitcost ) AS 'value of orders'
FROM customers, items, orders
WHERE customers.custID = orders.custID
AND orders.itemID = items.itemID
GROUP BY customers.state
LIMIT 0 , 50
Is there something wrong with it? 它有什么问题吗? It's giving answers that look like they might be correct, but some of them are just a tiny bit off when checked manually (none of the tables have more than fifty rows).
它给出了看起来可能正确的答案,但是当手动检查时,其中一些只是一点点关闭(没有一个表有超过五十行)。 This seems completely bizarre to me, and I can't work out what I'm doing wrong.
这对我来说似乎很奇怪,我无法弄清楚我做错了什么。
hope this will help:: 希望这会有所帮助::
SELECT
customers.state, SUM( orders.quantity * items.unitcost ) AS 'value of orders'
FROM
customers
inner join orders on (customers.custID = orders.custID)
inner join items on (orders.itemID = items.itemID),
GROUP BY customers.state
LIMIT 0 , 50
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.