Subject Re: [firebird-support] Re: union all and group by
Author Svein Erling Tysvaer
Yes, that seems like a good solution, Dimitry - though if there can be
rows in 'b' that aren't in 'a' (admittedly, there were no such case in
Maurizios example), 'coalesce(a.col1, b.col1) as col1' should be used
rather than simply 'a.col1'.

Set

Dimitry Sibiryakov wrote:
>> Though, thinking about it Dimitry, it is possible without WITH (and
>> hence, with older Firebird versions) through using subselects:
>
> If Firebird is not so old, I think it is also possible with SELECT
> FROM SELECT. Something like this:
>
> select a.col1, a.total1, b.total2 from
> (select cola1 as col1, sum(cola2) as total1 from tablea group by 1) a
> full join
> (select colb1 as col1, sum(colb2) as total2 from tableb group by 1) b
> on a.col1=b.col1
>
> Forgive me if I'm wrong again.
>
> SY, SD.