Problem with NOT IN portion of query.

From: Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
To: PGSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Problem with NOT IN portion of query.
Date: 2004-01-12 04:04:54
Message-ID: 20040111210454.4ee900ae.Robert_Creager@LogicalChaos.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hey All,

Probably doing something stupid, and I'm too tired to see what. The query I'm
trying to execute is:

SELECT date_trunc( 'hour', "when" )::timestamp AS
period FROM readings WHERE period NOT IN (SELECT "time" FROM
hour.summary_period) GROUP BY period ORDER BY period;

Where the table definitions are:

CREATE TABLE readings ( "when" TIMESTAMP DEFAULT now() NOT NULL PRIMARY KEY );
CREATE SCHEMA hour;
CREATE TABLE hour.summary_period ( "time" TIMESTAMP NOT NULL );

The error is:

ERROR: column "period" does not exist

When I remove the NOT IN (and associated WHERE), the query works fine.

Any help?

Cheers,
Rob

--
20:55:35 up 14 days, 10:45, 4 users, load average: 2.01, 2.04, 2.05

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Katarn 2004-01-12 05:18:36 Unique field key or several fks ?
Previous Message beyaRecords - The home Urban music 2004-01-12 01:09:43 Select into