Answer:
with productsales as
(select p.category,
p.name as productname,
sum(od.quantity) as totalsales
from orderdetails od
join products p on od.productid = p.productid
join suppliers s on p.supplierid = s.supplierid
group by p.category,
p.name)
select category,
productname,
totalsales,
rank() over (partition by category
order by totalsales desc) as salesrank,
sum(totalsales) over (partition by category
order by totalsales desc rows between unbounded preceding and current row) as runningsales
from productsales;