在我的ClassicModels.OrderDetails
表中,它有ProductCode
和QuantityOrdered
在我的ClassicModels.Products
表中,它有ProductLine
和ProductCode
现在,我需要编写一个SQL查询来查找尚未订购的任何产品系列
这是我的代码,但它不让我运行它,我无法弄清楚原因。
Select ProductLine from ClassicModels.Products
group by ProductLine
join
ClassicModels.OrderDetails
on ProductCode = ProductCode
having count(QuantityOrdered) > 0
答案 0 :(得分:0)
join
子句应该在from
子句之前,group by
子句之后直接出现:
SELECT ProductLine
FROM ClassicModels.Products
JOIN ClassicModels.OrderDetails ON ProductCode = ProductCode -- clause moved
GROUP BY ProductLine
HAVING COUNT(QuantityOrdered) > 0