我有这个密码:
Select firstname, lastname, sum(quantity) as quantitySum
FROM Customer
JOIN "Order"
ON Customer.id = "Order".customerid
JOIN orderitem
ON "Order".id = orderitem.orderid
WHERE country = 'Germany'
GROUP BY firstname, lastname
HAVING quantitySum > 500
ORDER BY lastname
但这给了我一个错误。我想不通。感谢你的帮助!
1条答案
按热度按时间jmp7cifd1#
Having
条款执行时间group by
然后select
所以你必须使用聚合函数having
如下所示