Re: Retrieving 'Credit' when 'C'

Lists: pgsql-sql
From: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Retrieving 'Credit' when 'C'
Date: 2007-02-15 16:17:46
Message-ID: 55c095e90702150817m3e462817qa792dba0e1916885@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hello,

Does anyone know how to make a Select that even having a Char(1) with the
letter C the statement makes the rows appearing 'CREDIT' ?

Like:
On table:

When Type
2007-01-01 C
2007-01-02 C
2007-01-03 C

On SQL result
When Type
2007-01-01 CREDIT
2007-01-02 CREDIT
2007-01-03 CREDIT

Thanks in advande,

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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/


From: Rodrigo De León <rdeleonp(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Retrieving 'Credit' when 'C'
Date: 2007-02-15 16:28:10
Message-ID: a55915760702150828h769483d4p2255157b52435483@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

SELECT CASE
WHEN TYPE = 'C'
THEN 'CREDIT'
END AS TYPE
FROM mytable


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Ezequias Rodrigues da Rocha <ezequias(dot)rocha(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Retrieving 'Credit' when 'C'
Date: 2007-02-15 16:30:14
Message-ID: 20070215163014.GP4682@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Ezequias Rodrigues da Rocha escribió:
> Hello,
>
> Does anyone know how to make a Select that even having a Char(1) with the
> letter C the statement makes the rows appearing 'CREDIT' ?

case when column = 'C' then 'CREDIT' end

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>
To: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Retrieving 'Credit' when 'C'
Date: 2007-02-15 16:44:36
Message-ID: 55c095e90702150844h3159bfbbx83c71b6910f4a88f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Just a question, where to put it ? I didn't notice yet.

Ezequias

2007/2/15, Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
>
> Ezequias Rodrigues da Rocha escribió:
> > Hello,
> >
> > Does anyone know how to make a Select that even having a Char(1) with
> the
> > letter C the statement makes the rows appearing 'CREDIT' ?
>
> case when column = 'C' then 'CREDIT' end
>
> --
> Alvaro Herrera
> http://www.CommandPrompt.com/
> The PostgreSQL Company - Command Prompt, Inc.
>

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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/


From: "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
To: "'Ezequias Rodrigues da Rocha'" <ezequias(dot)rocha(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Retrieving 'Credit' when 'C'
Date: 2007-02-15 21:47:14
Message-ID: 004001c7514a$daf02730$9b0014ac@wbaus090
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

SELECT when,

CASE WHEN type = 'C' THEN 'Credit' END AS type

FROM mytable;

Assuming your column names are actually "when" and "type" you should just
have to change "mytable" to the correct table name and run in psql or the
SQL Window of pgAdmin or wherever you usually run your SQL queries to get
what you want.

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org]
On Behalf Of Ezequias Rodrigues da Rocha
Sent: Friday, 16 February 2007 03:45
To: Ezequias Rodrigues da Rocha; pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Retrieving 'Credit' when 'C'

Just a question, where to put it ? I didn't notice yet.

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to
the addressee. If you are not the addressee indicated in this message or
responsible for delivery of the message to such person, you may not copy
or deliver this message to anyone, and you should destroy it and kindly
notify the sender by reply email.

Information in this message that does not relate to the official business
of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta.
Weatherbeeta, its employees, contractors or associates shall not be liable
for direct, indirect or consequential loss arising from transmission of this
message or any attachments


From: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>
To: "Phillip Smith" <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Retrieving 'Credit' when 'C'
Date: 2007-02-16 12:09:52
Message-ID: 55c095e90702160409m7bc87311q60fa92643ef2afe5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Perfect,

I learn this lesson now. This case is quite good.

My Best Regards
Ezequias

2007/2/15, Phillip Smith <phillip(dot)smith(at)weatherbeeta(dot)com(dot)au>:
>
> SELECT when,
>
> CASE WHEN type = 'C' THEN 'Credit' END AS type
>
> FROM mytable;
>
>
>
> Assuming your column names are actually "when" and "type" you should just
> have to change "mytable" to the correct table name and run in psql or the
> SQL Window of pgAdmin or wherever you usually run your SQL queries to get
> what you want.
>
>
>
>
>
> -----Original Message-----
> *From:* pgsql-sql-owner(at)postgresql(dot)org [mailto:
> pgsql-sql-owner(at)postgresql(dot)org] *On Behalf Of *Ezequias Rodrigues da Rocha
> *Sent:* Friday, 16 February 2007 03:45
> *To:* Ezequias Rodrigues da Rocha; pgsql-sql(at)postgresql(dot)org
> *Subject:* Re: [SQL] Retrieving 'Credit' when 'C'
>
>
>
> Just a question, where to put it ? I didn't notice yet.
>
> ********************Confidentiality and Privilege
> Notice********************
>
> The material contained in this message is privileged and confidential to
> the addressee. If you are not the addressee indicated in this message or
> responsible for delivery of the message to such person, you may not copy or
> deliver this message to anyone, and you should destroy it and kindly notify
> the sender by reply email.
>
> Information in this message that does not relate to the official business
> of Weatherbeeta must be treated as neither given nor endorsed by
> Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall
> not be liable for direct, indirect or consequential loss arising from
> transmission of this message or any attachments
>
>

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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/