Answer:
select distinct p.category,
last_value(p.name) over (partition by p.category
order by o.orderdate rows between unbounded preceding and unbounded following) as productname,
last_value(o.orderdate::date) over (partition by p.category
order by o.orderdate rows between unbounded preceding and unbounded following) as lastsolddate
from orderdetails od
join orders o on od.orderid = o.orderid
join products p on od.productid = p.productid
order by p.category;