Problem with NOT IN portion of query. - Mailing list pgsql-sql

From Robert Creager
Subject Problem with NOT IN portion of query.
Date
Msg-id 20040111210454.4ee900ae.Robert_Creager@LogicalChaos.org
Whole thread Raw
Responses Re: Problem with NOT IN portion of query.
List 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

pgsql-sql by date:

Previous
From: azwa@nc.com.my
Date:
Subject: Re: Missing data for column
Next
From: katarn
Date:
Subject: Unique key field or serverl fks ?