Thread: Case with Char(1)

Case with Char(1)

From
"Ezequias Rodrigues da Rocha"
Date:
Hi list,

it is possible to use case with character (1) ?

I am having problems to formate the SQL statement.

I have:

SELECT * FROM test;
a
---ABC


SELECT a,      CASE WHEN a='A' THEN 'one'           WHEN a='B' THEN 'two'           ELSE 'other'      END   FROM test;
a | case
---+-------A | oneB | twoC | other

I know from all program languages that case do not apply to noun
sequencialiable (if this word exists) variable (like integers etc).

Any help would be greatfull.

Thanks in advance
Ezequias


Re: Case with Char(1)

From
Andrew Sullivan
Date:
On Wed, Feb 28, 2007 at 10:02:38AM -0300, Ezequias Rodrigues da Rocha wrote:
> Hi list,
> 
> it is possible to use case with character (1) ?
> 
> I am having problems to formate the SQL statement.

Your example looked like it worked.

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Users never remark, "Wow, this software may be buggy and hard 
to use, but at least there is a lot of code underneath."    --Damien Katz


Re: Case with Char(1)

From
Peter Eisentraut
Date:
Am Mittwoch, 28. Februar 2007 14:02 schrieb Ezequias Rodrigues da Rocha:
> it is possible to use case with character (1) ?

Have you tried it?

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


Re: Case with Char(1)

From
"Ezequias Rodrigues da Rocha"
Date:
Now it is working. Thank you for your interest.
Ezequias

2007/2/28, Andrew Sullivan <ajs@crankycanuck.ca>:
> On Wed, Feb 28, 2007 at 10:02:38AM -0300, Ezequias Rodrigues da Rocha wrote:
> > Hi list,
> >
> > it is possible to use case with character (1) ?
> >
> > I am having problems to formate the SQL statement.
>
> Your example looked like it worked.
>
> A
>
> --
> Andrew Sullivan  | ajs@crankycanuck.ca
> Users never remark, "Wow, this software may be buggy and hard
> to use, but at least there is a lot of code underneath."
>                 --Damien Katz
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that your
>        message can get through to the mailing list cleanly
>


-- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=                                 Atenciosamente
(Sincerely)                      Ezequias Rodrigues da
Rocha=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
A pior das democracias ainda é melhor do que a melhor das ditaduras
The worst of democracies is still better than the better of dictatorships
http://ezequiasrocha.blogspot.com/