CASE not working

From: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: pgsql-sql(at)postgresql(dot)org
Subject: CASE not working
Date: 2005-03-21 14:18:38
Message-ID: 200503211118.39223.martin@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have this query which has a CASE in the middle to give me special results.
The problem is that it doesn't interpret my columns as it should.

Here is the porblem:

siprebi=> SELECT getvencimientosancion(190) AS vence, (SELECT codigo FROM
sanciones WHERE persona = (SELECT persona FROM usuarios WHERE codigo = 190)
ORDER BY femodif DESC LIMIT 1) AS sancion_original, CASE WHEN vence>=now()
THEN 1 ELSE 0 END AS sancionado;
ERROR: no existe la columna "vence"

(the translation of the error is: column "vence" does not exist).

I don't know what I'm getting wrong here.

--
11:12:48 up 2 days, 15:43, 2 users, load average: 0.95, 0.54, 0.56
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Alvaro Herrera 2005-03-21 14:29:31 Re: CASE not working
Previous Message osmar 2005-03-21 14:11:26 Accessing other Databases