From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Martín Marqués <martin@bugs.unl.edu.ar>
Cc: pgsql sql Mailing List <pgsql-sql@postgresql.org>
Subject: Re: case, new column not found
Date: Thu, 21 Jun 2001 16:46:07 -0700 (PDT)
Message-ID: <Pine.BSF.4.21.0106211639320.5673-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <01062120022108.16528@bugs>
On Thu, 21 Jun 2001, [iso-8859-1] Martín Marqués wrote:
> I'm trying somethings here and I get strange errors:
>
> select *,(
> (CASE WHEN titulo LIKE '%Matematica%' THEN 1 ELSE 0 END) +
> (CASE WHEN descripcion LIKE '%Matematica%' THEN 1 ELSE 0 END) +
> (CASE WHEN incumbencia LIKE '%Matematica%' THEN 1 ELSE 0 END) )
> AS encontrados
> FROM admin_view
> WHERE admin_view.nivel=1 AND encontrados > 0;
>
> ERROR: Attribute 'encontrados' not found
>
> Why is it? encontrados should be an attribute of type INT with the count of
> the rows found.
IIRC, unless "encontrados" is both a pre-existing column of
admin_view and the name you're using in the select, it's only an item in a
select list. It's not an attribute and since select list processing
happens after where clause processing (since you need to know which rows
to do it to -- imagine expensive computation in select list -- you
only want it to occur on returned rows) it isn't visible to the where
clause.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, martin@bugs.unl.edu.ar
Subject: Re: case, new column not found
In-Reply-To: <Pine.BSF.4.21.0106211639320.5673-100000@megazone23.bigpanda.com>
References: <01062120022108.16528@bugs> <Pine.BSF.4.21.0106211639320.5673-100000@megazone23.bigpanda.com>
* 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