Re: case, new column not found
От | Stephan Szabo |
---|---|
Тема | Re: case, new column not found |
Дата | |
Msg-id | Pine.BSF.4.21.0106211639320.5673-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | case, new column not found (Martín Marqués <martin@bugs.unl.edu.ar>) |
Список | pgsql-sql |
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.
В списке pgsql-sql по дате отправления: