Answer:
with category_spending as
(select c.customerid,
p.category,
sum(od.quantity * p.price) as totalspending
from orders o
join customers c on o.customerid = c.customerid
join orderdetails od on o.orderid = od.orderid
join products p on od.productid = p.productid
group by c.customerid,
p.category)
select customerid,
category,
totalspending,
rank() over (partition by category
order by totalspending desc) as spendingrank,
cume_dist() over (partition by category
order by totalspending desc) as spendingcumedist
from category_spending;