Subject RE: [firebird-support] doing a select in a Computed by column
Author Svein Erling Tysvær
>i'm not 100% sure about the second solution, but someone will soon
>correct me if i'm wrong :)

I would think changing the order of the tables (or replace LEFT with RIGHT) would be a more common solution (unless you want to sum all records that doesn't belong to an order), though if all orders of interest contain order items, then I think simply using JOIN would be the preferred solution).

So, something like:

select o.o_id_order, o.o_field1, o.o_field2, sum(oi.oi_price)
from order o
left join orderitem oi on o.o_id_order = oi.oi_id_order
where <whatever>
group by o.o_id_order, o.o_field1, o.o_field2

hth,
Set