I had to add the “Order by Category” before ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING. Thanks a lot for the help!
Select Category,
Hours,
100.0*Hours/(SUM(Hours) OVER (Order by Category ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING))Percentage
FROM (
Select Category, SUM(MaintTech1Hours + MaintTech2Hours + MaintTech3Hours + MaintTech4Hours + MaintTech5Hours) Hours
From WorkOrder (nolock)
Where DateTm Between DATEADD(month, DATEDIFF(month, 0, getDate()), 0) and DATEADD(month, DATEDIFF(month, -1, getDate()), -1)
Group by Category
) subq