From: Robert Creager <Robert_Creager@LogicalChaos.org>
To: Tomasz Myrta <jasiek@klaster.net>
Cc: PGSQL <pgsql-sql@postgresql.org>
Subject: Re: Problem with NOT IN portion of query.
Date: Mon, 12 Jan 2004 06:05:45 -0700
Message-ID: <20040112060545.59752f05.Robert_Creager@LogicalChaos.org> (raw)
In-Reply-To: <40023E79.10705@klaster.net>
References: <20040111210454.4ee900ae.Robert_Creager@LogicalChaos.org>
<40023E79.10705@klaster.net>
When grilled further on (Mon, 12 Jan 2004 07:28:09 +0100),
Tomasz Myrta <jasiek@klaster.net> confessed:
> Dnia 2004-01-12 05:04, U¿ytkownik Robert Creager napisa³:
> >
> > 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;
> >
> > The error is:
> >
> > ERROR: column "period" does not exist
> >
> Your problem has nothing to "NOT IN".
> Your query works fine, when you remove column alias from WHERE clause -
> it's beacause WHERE clause is executed *before* data output (and before
> column aliases). You can still use column aliases in "GROUP BY" and
> "ORDER BY".
Thanks for the info.
So now I have:
SELECT p.period FROM (SELECT date_trunc( 'hour', "when" )::timestamp AS period
FROM readings GROUP BY period) AS p WHERE p.period NOT IN (SELECT "time" FROM
hour.summary_period) ORDER BY p.period;
which appears works as expected. Anything obviously goofy with the above query?
Cheers,
Rob
--
05:57:10 up 14 days, 19:47, 4 users, load average: 2.17, 2.07, 2.04
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: Robert_Creager@LogicalChaos.org, jasiek@klaster.net
Subject: Re: Problem with NOT IN portion of query.
In-Reply-To: <20040112060545.59752f05.Robert_Creager@LogicalChaos.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox