pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow can I simply substatue a value in a query?
5+ messages / 5 participants
[nested] [flat]
* How can I simply substatue a value in a query?
@ 2005-06-27 17:16 Roy Souther <roy@SiliconTao.com>
0 siblings, 3 replies; 5+ messages in thread
From: Roy Souther @ 2005-06-27 17:16 UTC (permalink / raw)
To: pgsql-sql
I want to do a simple substatution of a value in a query. For example I
have a boolean field that wil return t or f for True and False. I would
like it to return Yes or No. I don't want to have a 2x2 table to look up
the output. I don't want to use stored procedue.
I think there is a better way, somthing very simple but I cannot
remember what it is.
Roy Souther
www.SiliconTao.com
Let Open Source help your business move beyond.
For security this message is digitally authenticated by GnuPG.
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I simply substatue a value in a query?
@ 2005-06-27 17:31 Sean Davis <sdavis2@mail.nih.gov>
parent: Roy Souther <roy@SiliconTao.com>
2 siblings, 0 replies; 5+ messages in thread
From: Sean Davis @ 2005-06-27 17:31 UTC (permalink / raw)
To: Roy Souther <roy@SiliconTao.com>; pgsql-sql
----- Original Message -----
From: Roy Souther
To: pgsql-sql@postgresql.org
Sent: Monday, June 27, 2005 1:16 PM
Subject: [SQL] How can I simply substatue a value in a query?
I want to do a simple substatution of a value in a query. For example I have a boolean field that wil return t or f for True and False. I would like it to return Yes or No. I don't want to have a 2x2 table to look up the output. I don't want to use stored procedue.
I think there is a better way, somthing very simple but I cannot remember what it is.
See CASE:
http://www.postgresql.org/docs/8.0/interactive/functions-conditional.html#AEN12006
Sean
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I simply substatue a value in a query?
@ 2005-06-27 17:35 Jim Buttafuoco <jim@contactbda.com>
parent: Roy Souther <roy@SiliconTao.com>
2 siblings, 0 replies; 5+ messages in thread
From: Jim Buttafuoco @ 2005-06-27 17:35 UTC (permalink / raw)
To: Roy Souther <roy@SiliconTao.com>; pgsql-sql
try case
for example
select case when bool_column then 'Yes' else 'No end from your_table;
---------- Original Message -----------
From: Roy Souther <roy@SiliconTao.com>
To: pgsql-sql@postgresql.org
Sent: Mon, 27 Jun 2005 11:16:58 -0600
Subject: [SQL] How can I simply substatue a value in a query?
> I want to do a simple substatution of a value in a query. For example I
> have a boolean field that wil return t or f for True and False. I would
> like it to return Yes or No. I don't want to have a 2x2 table to look up
> the output. I don't want to use stored procedue.
>
> I think there is a better way, somthing very simple but I cannot
> remember what it is.
>
> Roy Souther
> www.SiliconTao.com
> Let Open Source help your business move beyond.
>
> For security this message is digitally authenticated by GnuPG.
------- End of Original Message -------
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I simply substatue a value in a query?
@ 2005-06-27 17:45 Bryan Encina <bryan.encina@valleypres.org>
parent: Roy Souther <roy@SiliconTao.com>
2 siblings, 1 reply; 5+ messages in thread
From: Bryan Encina @ 2005-06-27 17:45 UTC (permalink / raw)
To: 'Roy Souther' <roy@SiliconTao.com>; pgsql-sql
-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Roy Souther
Sent: Monday, June 27, 2005 10:17 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] How can I simply substatue a value in a query?
I want to do a simple substatution of a value in a query. For example I have a boolean field that wil return t or f for True and False. I would like it to return Yes or No. I don't want to have a 2x2 table to look up the output. I don't want to use stored procedue.
I think there is a better way, somthing very simple but I cannot remember what it is.
-------------
I think a CASE statement is what you want. Check the Conditional Expressions section of the docs at:
http://www.postgresql.org/docs/8.0/interactive/functions-conditional.html
HTH,
Bryan Encina
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I simply substatue a value in a query?
@ 2005-06-27 18:18 davide <site.webmaster@email.it>
parent: Bryan Encina <bryan.encina@valleypres.org>
0 siblings, 0 replies; 5+ messages in thread
From: davide @ 2005-06-27 18:18 UTC (permalink / raw)
To: bryan.encina@valleypres.org; pgsql-sql
Bryan Encina wrote:
>-----Original Message-----
>From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Roy Souther
>Sent: Monday, June 27, 2005 10:17 AM
>To: pgsql-sql@postgresql.org
>Subject: [SQL] How can I simply substatue a value in a query?
>
>
>I want to do a simple substatution of a value in a query. For example I have a boolean field that wil return t or f for True and False. I would like it to return Yes or No. I don't want to have a 2x2 table to look up the output. I don't want to use stored procedue.
>
>I think there is a better way, somthing very simple but I cannot remember what it is.
>
>-------------
>
>I think a CASE statement is what you want. Check the Conditional Expressions section of the docs at:
>http://www.postgresql.org/docs/8.0/interactive/functions-conditional.html
>HTH,
>Bryan Encina
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 4: Don't 'kill -9' the postmaster
>
>
>
select case "field"
when 'T' then 'Yes'
when 'F' then 'No'
else null end
from ...
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2005-06-27 18:18 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-27 17:16 How can I simply substatue a value in a query? Roy Souther <roy@SiliconTao.com>
2005-06-27 17:31 ` Sean Davis <sdavis2@mail.nih.gov>
2005-06-27 17:35 ` Jim Buttafuoco <jim@contactbda.com>
2005-06-27 17:45 ` Bryan Encina <bryan.encina@valleypres.org>
2005-06-27 18:18 ` davide <site.webmaster@email.it>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox