I have 2 queries like :
select id, count(something) selected from table1...;
select id, count(something) rejected from table2...;
The first query gives me
id selected
------------
2 4
3 5
The second query gives me
id rejected
------------
1 12
3 13
I wish to combine them into the following form through a single query
id selected rejected
--------------------
1 null 12
2 4 null
3 5 13
How can I achieve this ?
You need to simulate
SQL Server‘sFULL OUTER JOINby combining theUNIONed results ofLEFT and RIGHTjoins (but in my case both areLEFT JOINas I used to to this)SQLFiddle Demo
UPDATE 1
PostgreSQL Supports
FULL OUTER JOIN(my bad)SQLFiddle Demo