Skip site navigation (1) Skip section navigation (2)

Re: Select case

From: "Chad Thompson" <chad(at)weblinkservices(dot)com>
To: "Doug Gorley" <douggorley(at)shaw(dot)ca>
Cc: "pgsql-novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Select case
Date: 2002-10-25 19:21:11
Message-ID: 100701c27c5b$ae87aab0$32021aac@chad (view raw or flat)
Thread:
Lists: pgsql-novice
Perfect!.   Thanks for the clarification.

Thanks
Chad
----- Original Message -----
From: "Doug Gorley" <douggorley(at)shaw(dot)ca>
To: "Chad Thompson" <chad(at)weblinkservices(dot)com>
Cc: "pgsql-novice" <pgsql-novice(at)postgresql(dot)org>
Sent: Friday, October 25, 2002 1:04 PM
Subject: Re: [NOVICE] Select case

select case field
       when 'Stuff' then 'Junk'
       when 'Crap'  then 'Darn'
       end
from table

That'd ought to do what you want.

On Fri, 2002-10-25 at 11:59, Chad Thompson wrote:
> I want to be able to change the results that are output from a query like
so.
>
> select field
> from table
> if field = 'Stuff' then 'Junk'
> elseif field  = 'Crap' then 'Darn'
>
> Since I am not quite sure what to look for, I have been unable to find
anything in the docs.  Select case doesnt seem to do what I want, but maybe
I just dont understand.
>
> Thanks
> Chad
--
Doug Gorley | douggorley(at)shaw(dot)ca     OpenPGP Key ID: 0xA221559B
Fingerprint: D707 DB92 E64B 69DA B8C7  2F65 C5A9 5415 A221 559B
Interested in public-key cryptography?    http://www.gnupg.org/




In response to

pgsql-novice by date

Next:From: Jonathon BatsonDate: 2002-10-25 22:34:59
Subject: Sequences Question
Previous:From: Doug GorleyDate: 2002-10-25 19:04:47
Subject: Re: Select case

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group