Subject Re: [firebird-support] UNION problem - column count error
Author Vlad Horsun
> I am trying to write a view which puts together values from several tables.
> All such tables have two columns, say "key" and "value". The SELECT command
> looks something like this:
>
> SELECT key, value, 0, 0, 0 FROM table_A
> UNION
> SELECT key, 0, value, 0, 0 FROM table_B
> UNION
> SELECT key, 0, 0, value, 0 FROM table_C
> UNION
> SELECT key, 0, 0, 0, value FROM table_D
>
> The idea is that this SELECT will be used in a view and I'll combine all
> values with
>
> SELECT key, SUM(value1), SUM(value2), SUM(value3), SUM(value4) FROM the_view

GROUP BY key ?

Regards,
Vlad