From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
Cc: | pgsql sql Mailing List <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: case, new column not found |
Date: | 2001-06-21 23:46:07 |
Message-ID: | Pine.BSF.4.21.0106211639320.5673-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, 21 Jun 2001, [iso-8859-1] Martn Marqus 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-06-21 23:49:31 | Re: case, new column not found |
Previous Message | Hugh Mandeville | 2001-06-21 21:29:41 | Re: Re: binary data |