I've read a few ways of doing this, but it does not seem to work for me. I'm trying to pull data that has a Category, Itemcode, and Sales. I'm summing this up for a period of time so that my basic query looks like this:
select
Category
, Itemcode
, sum(Sales)
, rank() over (partition by Category order by sum(Sales) desc) as ItemRank
from
Sales
group by
Category, Itemcode
When I do that, my data looks like this:
What I would like to do is to add another rank that would show the rank of the Category as a whole.
Something like this:
What would the query look like with that added in? I've tried several things, but I can't seem to get it to work.

