From: Tom Lane <tgl@sss.pgh.pa.us>
To: Markus Bertheau <twanger@bluetwanger.de>
Cc: postgres sql list <pgsql-sql@postgresql.org>
Subject: Re: why can a named subselect not be used in a where condition?
Date: Thu, 24 Jan 2002 13:24:22 -0500
Message-ID: <16339.1011896662@sss.pgh.pa.us> (raw)
In-Reply-To: <1011894031.29186.24.camel@entwicklung01.cenes.de>
References: <1011894031.29186.24.camel@entwicklung01.cenes.de>
Markus Bertheau <twanger@bluetwanger.de> writes:
> cenes_test=3D> select personen.*, (select max(last_visit) from sessions
> where sessions.personen_id =3D personen.personen_id) as max from personen
> where max between 1009148400 and 1011913200 order by max desc;
> ERROR: Attribute 'max' not found
> Well, why can't I use max in the where clause?
Because max is computed by the select's output list, which logically is
a stage of processing after WHERE. Perhaps you need to buy an SQL
textbook.
> cenes=> select personen.*, (select max(last_visit) from sessions where
> sessions.personen_id = personen.personen_id) from personen where (select
> max(zeitstempel) from sessions where sessions.personen_id =
> personen.personen_id) between 1009148400 and 1011913200;
> ERROR: ExecEvalExpr: unknown expression type 501
> That is a query we have tried on 7.0.2 because of curiosity. But the
> error message looks weird. What does it mean?
This is an internal error. I couldn't reproduce the error using 7.0.2
and straightforward table definitions. I suspect you've not told us
something important, like that one of these things is a view with a
nontrivial definition. In any case, 7.0.2 is a long ways back and I'm
not very concerned about figuring out exactly why it fails. If you can
reproduce the problem on a current release (7.1.3 or 7.2beta) I'd be
interested...
regards, tom lane
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: tgl@sss.pgh.pa.us, twanger@bluetwanger.de
Subject: Re: why can a named subselect not be used in a where condition?
In-Reply-To: <16339.1011896662@sss.pgh.pa.us>
* 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