どんなデータの持ち方なのか、なぞですが。たとえば。
sql
1with
2may as (
3 select ..., null as column_B from ...
4),
5june as (
6 select ..., null as column_A from ...
7),
8hoge as (
9 select * from may union select * from june
10)
11select * from hoge where column_A = '1' or column_B = '1'
12;
しかし
error: syntax error at or near "null"
と言われてしまいました
とのコメントを受けての追記。
sql
1create table xx (id text, name text, column_A text);
2create table yy (id text, name text, column_B text);
3
4insert into xx VALUES
5 ('0501', 'aaa', '0'),
6 ('0502', 'bbb', '1'),
7 ('0503', 'ccc', '0')
8 ;
9
10insert into yy VALUES
11 ('0661', 'ooo', '0'),
12 ('0662', 'ppp', '1'),
13 ('0663', 'qqq', '1')
14 ;
sql
1with
2may as (
3 select id, name, column_A, null as column_B from xx
4),
5june as (
6 select id, name, null as column_A, column_B from yy
7),
8hoge as (
9 select * from may union select * from june
10)
11select * from hoge where column_A = '1' or column_B = '1'
12;
id | name | column_a | column_b
------+------+----------+----------
0502 | bbb | 1 |
0662 | ppp | | 1
0663 | qqq | | 1
(3 行)