select
    o.id
    ,os.status
    --,ps.*
    ,p.id
    ,c.*
 from "order" o
inner join order_status os on os.id = o.order_status_id
inner join order_products_sold ops on ops.order_id = o.id
inner join products_sold ps on ps.id = ops.products_sold_id
inner join product p on p.id = ps.product_id
inner join category c on c.id = p.category_id


-----------
select
    sum(ps.price)
    ,c.name
from "order" o
inner join order_status os on os.id = o.order_status_id
inner join order_products_sold ops on ops.order_id = o.id
inner join products_sold ps on ps.id = ops.products_sold_id
inner join product p on p.id = ps.product_id
inner join category c on c.id = p.category_id
where os.status = 'FINALIZADO'
group by c.name