I need to create a schema that gives the output of the number of customers in a given territory.
So far, I've written up this, and it only displays the TerritoryID and the number of orders. I would like to add another column from a different table to show the description for the TerritoryID. Specificially, the column TerritoryName from the table Territories. How do I add it to the script I've written up? Should I use UNION?
SELECT EmployeeTerritories.TerritoryID, COUNT(Orders.CustomerID) AS Orders
FROM EmployeeTerritories
JOIN Orders ON Orders.EmployeeID = EmployeeTerritories.EmployeeID
GROUP BY EmployeeTerritories.TerritoryID
ORDER BY COUNT(Orders.CustomerID) DESC;