SELECT id as order_id , (SELECT SUM(order_item.quantity * products.price) FROM order_item INNER JOIN products ON order_item.product_id = products.id WHERE order_item.order_id = orders.id ) as total FROM orders;
{ "a" : { "b" : 10 } }
{ "a" : { "b" : 8 } }
{ "a" : { "b" : 15 } }