select order_id, sum(quantity * price) as total from prices inner join orders on prices.item_id = orders.item_id group by order_id order by sum(quantity * price)
select order_id, sum(quantity * price) as total from prices inner join orders on prices.item_id = orders.item_id group by order_id order by total
First query overflows stack, second query works.