Case sobre alias

From: Douglas <douglas(dot)rauber(at)gmail(dot)com>
To: pgsql-pt-geral(at)lists(dot)postgresql(dot)org
Subject: Case sobre alias
Date: 2018-10-02 18:29:30
Message-ID: CAOoRPSXwUjUpLoxTjzMVvR38Tieb1ZTjkOyM4g+N=vKqrUKbFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-pt-geral

Boa tarde!

Eu gostaria de fazer um query assim:

select
case tab.colunaA
when 'A' then 'Ok'
when 'B' then 'Ok'
when 'C' then 'Ok'
when 'D' then 'Ok'
when 'E' then 'Err'
when 'F' then 'Err'
when 'G' then 'Err'
end as resultadoA,
case resultadoA when 'Err' then 'Problemas' end as complemento
from tab

Mas recebo o retorno column "resultadoA" does not exist.

Como posso fazer para usar o resultado da coluna nomeada?

Obrigado.

Douglas

Responses

Browse pgsql-pt-geral by date

  From Date Subject
Next Message Sebastian Webber 2018-10-02 18:33:41 Re: Case sobre alias
Previous Message Carlos Adean 2018-10-01 14:43:05 Re: Quota por usuário no postgreSQL