尝试使用连接在组上执行此代码,但它给出了错误,即它不是按语句分组
下面的代码
SELECT
sum (quantity),
customers.customer_name,
states.state_name,
regions.region_name
FROM sales JOIN customers ON sales.customer_id = customers.customer_id
join states on customers.state_id = states.state_id
join regions on states.region_id = regions.region_idhaving sum(quantity) >= 10
GROUP BY sales.sale_id, customers.customer_name, states.state_name, regions.region_id
;
通过表达不是一个群体。
答案 0 :(得分:0)
having
子句位于group by
之后。但是你应该学会使用表别名,这样你的查询就更容易编写和阅读。
此外,您需要region_name
中的GROUP BY
:
SELECT sum(quantity), c.customer_name, st.state_name, r.region_name
FROM sales s JOIN
customers c
ON s.customer_id = c.customer_id JOIN
states st
ON c.state_id = st.state_id JOIN
regions r
ON s.region_id = r.region_id
GROUP BY s.sale_id, c.customer_name, st.state_name, r.region_name
HAVING sum(quantity) >= 10
答案 1 :(得分:0)
您在self.translate.x, self.translate.y = self.my_pos
中使用的任何不属于汇总操作的内容(例如SELECT
)都需要包含在SUM
声明中