Re: ERROR: missing FROM-clause entry for table

From: Roxanne Reid-Bennett <rox(at)tara-lu(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: missing FROM-clause entry for table
Date: 2016-02-10 08:02:33
Message-ID: 56BAEE99.1070509@tara-lu.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/9/2016 11:11 PM, bigkev wrote:
> I am receiving this error for the query pasted below.
> Is the LEFT JOIN on the table not enough?
> What needs to happen here?
> I am guess something to do with derived tables
>
> http://pastie.org/10715876
>

Your error is in the reference to c.start_time, c.end_time. During the
parse, the system doesn't know about "c" yet.
and swapping fortnight and "c" won't help - you can't reference
c.start_time in the "from" portion of the join.

So - substituting static values for c.start_time, c.end_time :
select * FROM generate_series('2016-01-22', '2017-12-31', '1
day'::interval) g(day)
left join generate_series('2015-01-25', '2016-07-01', '2
weeks'::interval) f(fortnight) ON g.day=f.fortnight

generates results... but I'm not sure it is giving you what you want.

Exactly what are you trying to achieve with the fortnight construct?
BTW - assuming call_schedule.start_time is a timestamp... do your
start/end times cross day boundaries? the test g.day between start/end
will never be true otherwise - you are dealing with "midnight" values
for time.
e.g. '2016-01-23' does not fall between '2016-01-23 08:30:01' and
"2016-01-23 10:45:01'

Roxanne

--
[At other schools] I think the most common fault in general is to teach students how to pass exams instead of teaching them the science.
Donald Knuth

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Achilleas Mantzios 2016-02-10 08:34:53 Re: PostgreSQL vs Firebird SQL
Previous Message Charles Clavadetscher 2016-02-10 07:45:09 Re: ERROR: missing FROM-clause entry for table