Subject Re: [firebird-support] UNION problem - column count error
Author Martijn Tonies

> I am trying to write a view which puts together values from several
> All such tables have two columns, say "key" and "value". The SELECT
> looks something like this:
> SELECT key, value, 0, 0, 0 FROM table_A
> SELECT key, 0, value, 0, 0 FROM table_B
> SELECT key, 0, 0, value, 0 FROM table_C
> 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
> But for some strange reason I am getting an error number -104 ("count of
> column list and variable list do not match"). I even tried to CAST all
> columns, without success - as soon as I try the first union, I get the
> error. Is that a bug in Firebird (1.5.3 Win32 SuperServer) or did I miss
> something?

When are you getting that error, on executing your UNION select, or
when creating the view? If the latter, try naming the columns:

create view myview (key, value1, value2, value3, value4)
as SELECT ...

Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
My thoughts:
Database development questions? Check the forum!