I've written a count query which isn't working, as expected. 
The query is below and it returns three columns - DeparmtmentName, CategoryName and NumberOfCats. 

The NumberOfCats column should show the number of Categories in a given Department. 

So with the table below, the NumberOfCats column should have the number 4 in each row, instead of 1, because the Bakey Department has 4 Categories, in this case. 

Does anyone know how I can amend the code, so it returns the right result, please? 

[![enter image description here](https://i.stack.imgur.com/hXHxs.png)](https://i.stack.imgur.com/hXHxs.png)

```
SELECT 
        DepartmentName,
        CategoryName,       
        COUNT(DISTINCT CategoryName) as NumberOfCats
FROM v_EnterpriseStructure
GROUP BY 
        DepartmentName,
        CategoryName
ORDER BY DepartmentName; 

```