SELECT Customer.CID, Count(Order.OrderID) AS [# Orders]
FROM Customer INNER JOIN [Order] ON Customer.CID = Order.CID
Group By Customer.CID DESC;
我试图按降序列出客户的订单总数。我在group by子句中遇到语法错误。我不确定语法错误是什么。
答案 0 :(得分:3)
你错过了你的ORDER BY子句。您的查询应如下所示:
SELECT Customer.CID, Count(Order.OrderID) AS [# Orders]
FROM Customer INNER JOIN [Order] ON Customer.CID = Order.CID
GROUP BY Customer.CID
ORDER BY Customer.CID DESC;
答案 1 :(得分:1)
您应该使用order by
代替group by
所以你的新查询将是,
SELECT Customer.CID, Count(Order.OrderID) AS [# Orders]
FROM Customer INNER JOIN [Order] ON Customer.CID = Order.CID
Order By Customer.CID DESC;
我没有桌子。所以请提供你的评论。