Re: [SQL] Problem with nested left-joins and coalesce

2011-08-08 Thread Carla
; > sub4 ON sub4.key5=sub3.key3**** > > )**** > > sub2 ON sub1.key1 = sub2.key3 > > ** ** > > best regards, > > alex > > ** ** > > *From:* pgsql-sql-ow...@postgresql.org [mailto: > pgsql-sql-ow...@postgresql.org] *On Behalf Of *Carla

Re: [SQL] Problem with nested left-joins and coalesce

2011-08-08 Thread ai
b4.key5=sub3.key3 ) sub2 ON sub1.key1 = sub2.key3 best regards, alex From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Carla Sent: Monday, August 08, 2011 10:03 PM To: ai Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Problem with nested left-joins a

Re: [SQL] Problem with nested left-joins and coalesce

2011-08-08 Thread Carla
Hi Alex! When you wrote "COALESCE(sub6.value1, 1) as value2", you created a column "value2" that is different of the original column "sub4.value2". Try running "SELECT sub3.key3, sub4.value2, value2 FROM ..." and you'll get the result: key1;key3;value2;value2 1;1;null;1 It happens because the firs

[SQL] Problem with nested left-joins and coalesce

2011-08-07 Thread ai
Hi! I have strange issue with nested left-joins in postgresql... It's hard to explain, but easy to show =) here we are: SELECT * FROM ( SELECT 1 as key1 ) sub1 LEFT JOIN ( SELECT sub3.key3, value2 FROM (