Re: CTE or Subselect and outer joins not behaving as expected?

From: Joel Stevenson <jstevenson(at)bepress(dot)com>
To: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: CTE or Subselect and outer joins not behaving as expected?
Date: 2011-10-26 17:22:34
Message-ID: 3F900D3A-B43A-4FBD-870B-88FB6C8E875D@bepress.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ah, yes! Thanks for the help.

On Oct 25, 2011, at 5:42 AM, Harald Fuchs wrote:

> Joel Stevenson <jstevenson(at)bepress(dot)com> writes:
>
> Your WHERE clause turns the OUTER into an INNER JOIN. Try
>
> select tally_table.tally_mon, met.datum
> from (
> select distinct date_trunc( 'month', '2011-06-01'::date + tally_day )::date as tally_mon
> from generate_series( 0, ( select current_date - '2011-06-01'::date ) ) as tally_day
> ) as tally_table
> left join my_existing_table as met on tally_mon = met.month and met.series = 1;

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Federico Dal Maso 2011-10-27 10:28:28 How to obtain a coalesce aggregation in a GROUP BY query?
Previous Message Ty Busby 2011-10-25 18:37:02 optimize self-join query