Subject | UNION problem - column count error |
---|---|
Author | PenWin |
Post date | 2006-12-27T12:02:53Z |
Hi!
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
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?
(For those curious, using LEFT JOINs instead of UNIONs takes too long; I
lost patience after 20 minutes)
Thanks,
Pepak
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
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?
(For those curious, using LEFT JOINs instead of UNIONs takes too long; I
lost patience after 20 minutes)
Thanks,
Pepak