Answer:
with categorysales as
(select p.category,
p.productid,
sum(od.quantity * p.price) as totalrevenue
from orderdetails od
join products p on od.productid = p.productid
group by p.category,
p.productid)
select category,
productid,
totalrevenue,
dense_rank() over (partition by category
order by totalrevenue desc) as rank
from categorysales;