First and Foremost, this is part of an assignment.
I am trying to use the COUNT function as part of a query in relation to the Northwind database. The query should retur
You need a group by clause, which will allow you to split your result in to groups, and perform the aggregate function (count, in this case), per group:
SELECT Customers.CustomerID, Customers.CompanyName, COUNT(*)
FROM Orders, Customers
WHERE Customers.CustomerID = Orders.CustomerID;
GROUP BY Customers.CustomerID, Customers.CompanyName
Note: Although this is not part of the question, it's recommended to use explicit joins instead of the deprecated implicit join syntax you're using. In this case, the query would look like:
SELECT Customers.CustomerID, Customers.CompanyName, COUNT(*)
FROM Orders
JOIN Customers ON Customers.CustomerID = Orders.CustomerID;
GROUP BY Customers.CustomerID, Customers.CompanyName