Unix Technical Forum

Case with Char(1)

This is a discussion on Case with Char(1) within the pgsql Sql forums, part of the PostgreSQL category; --> Hi list, it is possible to use case with character (1) ? I am having problems to formate the ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 03:09 PM
Ezequias Rodrigues da Rocha
 
Posts: n/a
Default Case with Char(1)

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
---
A
B
C


SELECT a,
CASE WHEN a='A' THEN 'one'
WHEN a='B' THEN 'two'
ELSE 'other'
END
FROM test;

a | case
---+-------
A | one
B | two
C | 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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:09 PM
Andrew Sullivan
 
Posts: n/a
Default Re: Case with Char(1)

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 03:09 PM
Peter Eisentraut
 
Posts: n/a
Default Re: Case with Char(1)

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/

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 03:09 PM
Ezequias Rodrigues da Rocha
 
Posts: n/a
Default Re: Case with Char(1)

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/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:10 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com